public static function Rule::preDelete in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Entity/Rule.php \Drupal\rng\Entity\Rule::preDelete()
- 3.x src/Entity/Rule.php \Drupal\rng\Entity\Rule::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 EntityBase::preDelete
File
- src/
Entity/ Rule.php, line 166
Class
- Rule
- Defines the event rule entity.
Namespace
Drupal\rng\EntityCode
public static function preDelete(EntityStorageInterface $storage, array $entities) {
$component_storage = \Drupal::entityTypeManager()
->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);
}