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