You are here

public static function Micon::preDelete in Micon 8

Same name and namespace in other branches
  1. 2.x src/Entity/Micon.php \Drupal\micon\Entity\Micon::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 ConfigEntityBase::preDelete

File

src/Entity/Micon.php, line 244

Class

Micon
Defines the Micon entity.

Namespace

Drupal\micon\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {
  parent::preDelete($storage, $entities);
  foreach ($entities as $entity) {

    // Remove all files within package directory.
    file_unmanaged_delete_recursive($entity
      ->getDirectory());

    // Clean up empty directory. Will fail silently if it is not empty.
    @rmdir($entity->directory);
  }
}