/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { parent::preDelete($storage, $entities); /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); foreach ($entities as $menu_link) { /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */ $menu_link_manager->removeDefinition($menu_link->getPluginId(), FALSE); } }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { parent::preDelete($storage, $entities); // Ensure that all nodes deleted are removed from the search index. if (\Drupal::moduleHandler()->moduleExists('search')) { foreach ($entities as $entity) { search_index_clear('node_search', $entity->nid->value); } } }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { parent::preDelete($storage, $entities); foreach ($entities as $entity) { // Delete all remaining references to this file. $file_usage = \Drupal::service('file.usage')->listUsage($entity); if (!empty($file_usage)) { foreach ($file_usage as $module => $usage) { \Drupal::service('file.usage')->delete($entity, $module); } } // Delete the actual file. Failures due to invalid files and files that // were already deleted are logged to watchdog but ignored, the // corresponding file entity will be deleted. file_unmanaged_delete($entity->getFileUri()); } }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { $registrant_storage = \Drupal::entityManager()->getStorage('registrant'); /** @var \Drupal\rng\RegistrationInterface $registration */ foreach ($entities as $registration) { // Delete associated registrants. $ids = $registrant_storage->getQuery()->condition('registration', $registration->id(), '=')->execute(); $registrants = $registrant_storage->loadMultiple($ids); $registrant_storage->delete($registrants); } parent::preDelete($storage, $entities); }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { // We need to check whether the state of the job is affected by this // deletion. foreach ($entities as $entity) { if ($job = $entity->getJob()) { // We only care for active jobs. if ($job->isActive() && tmgmt_job_check_finished($job->id())) { // Mark the job as finished. $job->finished(); } } } parent::preDelete($storage, $entities); }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { $component_storage = \Drupal::entityManager()->getStorage('rng_rule_component'); /** @var \Drupal\rng\RuleInterface $rule */ foreach ($entities as $rule) { // Delete associated rule components. $ids = $component_storage->getQuery()->condition('rule', $rule->id())->execute(); $components = $component_storage->loadMultiple($ids); $component_storage->delete($components); } parent::preDelete($storage, $entities); }