public static function Workspace::postDelete in Drupal 8
Same name and namespace in other branches
- 9 core/modules/workspaces/src/Entity/Workspace.php \Drupal\workspaces\Entity\Workspace::postDelete()
- 10 core/modules/workspaces/src/Entity/Workspace.php \Drupal\workspaces\Entity\Workspace::postDelete()
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but 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::postDelete
File
- core/
modules/ workspaces/ src/ Entity/ Workspace.php, line 181
Class
- Workspace
- The workspace entity class.
Namespace
Drupal\workspaces\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Add the IDs of the deleted workspaces to the list of workspaces that will
// be purged on cron.
$state = \Drupal::state();
$deleted_workspace_ids = $state
->get('workspace.deleted', []);
$deleted_workspace_ids += array_combine(array_keys($entities), array_keys($entities));
$state
->set('workspace.deleted', $deleted_workspace_ids);
// Trigger a batch purge to allow empty workspaces to be deleted
// immediately.
\Drupal::service('workspaces.manager')
->purgeDeletedWorkspacesBatch();
}