public static function Micon::preDelete in Micon 2.x
Same name and namespace in other branches
- 8 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 251 
Class
- Micon
- Defines the Micon entity.
Namespace
Drupal\micon\EntityCode
public static function preDelete(EntityStorageInterface $storage, array $entities) {
  parent::preDelete($storage, $entities);
  foreach ($entities as $entity) {
    // Remove all files within package directory.
    \Drupal::service('file_system')
      ->deleteRecursive($entity
      ->getDirectory());
    // Clean up empty directory. Will fail silently if it is not empty.
    @rmdir($entity->directory);
  }
}