public function Flag::preSave in Flag 8.4
Acts on an entity before the presave hook is invoked.
Used before the entity is saved and before invoking the presave hook.
Ensure that config entities which are bundles of other entities cannot have their ID changed.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
Throws
\Drupal\Core\Config\ConfigNameException Thrown when attempting to rename a bundle entity.
Overrides ConfigEntityBundleBase::preSave
File
- src/
Entity/ Flag.php, line 459
Class
- Flag
- Provides the Flag configuration entity.
Namespace
Drupal\flag\EntityCode
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
$bundles = array_filter($this
->get('bundles'));
sort($bundles);
$this
->set('bundles', $bundles);
/*
// Save the Flag Type configuration.
$flagTypePlugin = $this->getFlagTypePlugin();
$this->set('flagTypeConfig', $flagTypePlugin->getConfiguration());
// Save the Link Type configuration.
$linkTypePlugin = $this->getLinkTypePlugin();
$this->set('linkTypeConfig', $linkTypePlugin->getConfiguration());
*/
// Reset the render cache for the entity.
\Drupal::entityTypeManager()
->getViewBuilder($this
->getFlaggableEntityTypeId())
->resetCache();
// Clear entity extra field caches.
// @todo Inject the entity field manager into the object?
\Drupal::service('entity_field.manager')
->clearCachedFieldDefinitions();
}