function WorkspaceProviderBase::entityPredelete
Acts before an entity is deleted.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity being deleted.
Overrides WorkspaceProviderInterface::entityPredelete
File
-
core/
modules/ workspaces/ src/ Provider/ WorkspaceProviderBase.php, line 237
Class
- WorkspaceProviderBase
- Defines the base class for workspace providers.
Namespace
Drupal\workspaces\ProviderCode
public function entityPredelete(EntityInterface $entity) : void {
// Prevent the entity from being deleted if the entity type does not have
// support for workspaces, or if the entity has a published default
// revision.
$active_workspace = $this->workspaceManager
->getActiveWorkspace();
if (!$this->workspaceInfo
->isEntitySupported($entity) || !$this->workspaceInfo
->isEntityDeletable($entity, $active_workspace)) {
throw new \RuntimeException("This {$entity->getEntityType()->getSingularLabel()} can only be deleted in the Live workspace.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.