function ShortcutSet::preDelete

Same name in other branches
  1. 9 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::preDelete()
  2. 8.9.x core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::preDelete()
  3. 10 core/modules/shortcut/src/Entity/ShortcutSet.php \Drupal\shortcut\Entity\ShortcutSet::preDelete()

Overrides ConfigEntityBase::preDelete

File

core/modules/shortcut/src/Entity/ShortcutSet.php, line 98

Class

ShortcutSet
Defines the Shortcut set configuration entity.

Namespace

Drupal\shortcut\Entity

Code

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')->accessCheck(FALSE)
            ->condition('shortcut_set', $entity->id(), '=')
            ->execute();
        $controller = \Drupal::entityTypeManager()->getStorage('shortcut');
        $entities = $controller->loadMultiple($shortcut_ids);
        $controller->delete($entities);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.