You are here

public static function Group::preDelete in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Group.php \Drupal\group\Entity\Group::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/Group.php, line 379

Class

Group
Defines the Group entity.

Namespace

Drupal\group\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {

  // Remove all group content from these groups as well.
  foreach ($entities as $group) {
    foreach ($group
      ->getContent() as $group_content) {
      $group_content
        ->delete();
    }
  }
}