protected function FilterFormatStorageController::preSave

Overrides \Drupal\Core\Config\Entity\ConfigStorageController::preSave().

Overrides ConfigStorageController::preSave

File

drupal/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php, line 21
Contains \Drupal\filter\FilterFormatStorageController.

Class

FilterFormatStorageController
Defines the storage controller class for Filter Format entities.

Namespace

Drupal\filter

Code

protected function preSave(EntityInterface $entity) {
  parent::preSave($entity);
  $entity->name = trim($entity
    ->label());

  // @todo Do not save disabled filters whose properties are identical to
  //   all default properties.
  // Determine whether the format can be cached.
  // @todo This is a derived/computed definition, not configuration.
  $entity->cache = TRUE;
  foreach ($entity
    ->filters() as $filter) {
    if ($filter->status && !$filter->cache) {
      $entity->cache = FALSE;
    }
  }
}