function ReactionRuleStorage::delete
Overrides EntityStorageBase::delete
File
-
src/
Entity/ ReactionRuleStorage.php, line 146
Class
- ReactionRuleStorage
- Storage handler for Reaction Rule configuration entities.
Namespace
Drupal\rules\EntityCode
public function delete(array $entities) {
// When a rule is deleted the cache for its event(s) must be invalidated.
foreach ($entities as $entity) {
Cache::invalidateTags($entity->getEventNames());
}
// After deleting a set of reaction rules, sometimes we may need to rebuild
// the container, to clean it up, so that the generic subscriber is not
// registered in the container for the rule events which we do not use
// anymore. So we do that if there is any change in the registered events,
// after the reaction rules are deleted.
$events_before = $this->getRegisteredEvents();
$return = parent::delete($entities);
$events_after = $this->getRegisteredEvents();
// Update the state of registered events and rebuild the container.
if ($events_before != $events_after) {
$this->stateService
->set('rules.registered_events', $events_after);
$this->drupalKernel
->rebuildContainer();
}
return $return;
}