public static function ShortcutSet::preDelete in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::preDelete()
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides ConfigEntityBase::preDelete
File
- core/
modules/ shortcut/ src/ Entity/ ShortcutSet.php, line 90 - Contains \Drupal\shortcut\Entity\ShortcutSet.
Class
- ShortcutSet
- Defines the Shortcut set configuration entity.
Namespace
Drupal\shortcut\EntityCode
public static function preDelete(EntityStorageInterface $storage, array $entities) {
parent::preDelete($storage, $entities);
foreach ($entities as $entity) {
$storage
->deleteAssignedShortcutSets($entity);
// Next, delete the shortcuts for this set.
$shortcut_ids = \Drupal::entityQuery('shortcut')
->condition('shortcut_set', $entity
->id(), '=')
->execute();
$controller = \Drupal::entityManager()
->getStorage('shortcut');
$entities = $controller
->loadMultiple($shortcut_ids);
$controller
->delete($entities);
}
}