You are here

public function ViewmodepagePattern::preSave in View Mode Page 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Entity/ViewmodepagePattern.php \Drupal\view_mode_page\Entity\ViewmodepagePattern::preSave()
  2. 3.2.x src/Entity/ViewmodepagePattern.php \Drupal\view_mode_page\Entity\ViewmodepagePattern::preSave()

Not using core's default logic around ConditionPluginCollection since it incorrectly assumes no condition will ever be applied twice.

Overrides ConfigEntityBase::preSave

File

src/Entity/ViewmodepagePattern.php, line 150

Class

ViewmodepagePattern
Defines the Viewmodepage pattern entity.

Namespace

Drupal\view_mode_page\Entity

Code

public function preSave(EntityStorageInterface $storage) {
  parent::preSave($storage);
  $criteria = [];
  foreach ($this
    ->getSelectionConditions() as $id => $condition) {
    $criteria[$id] = $condition
      ->getConfiguration();
  }
  $this->selection_criteria = $criteria;

  // Clear the cache.
  \Drupal::service('cache.data')
    ->deleteAll();
}