public function JobItem::preSave

File

src/Entity/JobItem.php, line 185

Class

JobItem
Entity class for the tmgmt_job_item entity.

Namespace

Drupal\tmgmt\Entity

Code

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