You are here

function opigno_group_manager_entity_delete in Opigno group manager 3.x

Same name and namespace in other branches
  1. 8 opigno_group_manager.module \opigno_group_manager_entity_delete()

Implements hook_entity_delete().

File

./opigno_group_manager.module, line 274
Contains opigno_group_manager.module.

Code

function opigno_group_manager_entity_delete(EntityInterface $entity) {
  if ($entity instanceof GroupInterface) {
    try {

      /* @var \Drupal\opigno_group_manager\Entity\OpignoGroupManagedContent[] $opigno_group_managed_contents */
      $opigno_group_managed_contents = OpignoGroupManagedContent::loadByGroupId($entity
        ->id());
      if (count($opigno_group_managed_contents)) {
        foreach ($opigno_group_managed_contents as $opigno_group_managed_content) {
          $opigno_group_managed_content
            ->delete();
        }
      }
    } catch (PluginNotFoundException|InvalidPluginDefinitionException|EntityStorageException $e) {
      watchdog_exception('opigno_group_manager', $e);
    }
  }
}