public static function FlaggingCollection::preDelete in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/Entity/FlaggingCollection.php \Drupal\flag_lists\Entity\FlaggingCollection::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/ FlaggingCollection.php, line 173
Class
- FlaggingCollection
- Defines the Flagging collection entity.
Namespace
Drupal\flag_lists\EntityCode
public static function preDelete(EntityStorageInterface $storage, array $entities) {
// When a Flagging Collection is deleted also delete the
// related Flag.
$flagService = \Drupal::service('flag');
foreach ($entities as $entity) {
$flag = $flagService
->getFlagById($entity
->getRelatedFlag()
->id());
$flag
->delete();
}
parent::preDelete($storage, $entities);
}