public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
if ($this
->getTask()) {
$this
->recalculateStatistics();
}
if ($this->unserializedData) {
$this
->set('data', Json::encode($this->unserializedData));
}
elseif (empty($this
->get('data')->value)) {
$this
->set('data', Json::encode(array()));
}
}