public function LocalTaskItem::preSave

File

translators/tmgmt_local/src/Entity/LocalTaskItem.php, line 252

Class

LocalTaskItem
Entity class for the local task item entity.

Namespace

Drupal\tmgmt_local\Entity

Code

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()));
  }
}