function WorkspaceSafeFormTrait::isWorkspaceSafeEntity

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Form/WorkspaceSafeFormTrait.php \Drupal\Core\Entity\Form\WorkspaceSafeFormTrait::isWorkspaceSafeEntity()

Determines whether an entity used in a form is workspace-safe.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity object.

Return value

bool TRUE if the entity is workspace-safe, FALSE otherwise.

1 call to WorkspaceSafeFormTrait::isWorkspaceSafeEntity()
WorkspaceSafeFormTrait::isWorkspaceSafeForm in core/modules/layout_builder/src/Form/WorkspaceSafeFormTrait.php
Determines whether the current form is safe to be submitted in a workspace.

File

core/lib/Drupal/Core/Entity/Form/WorkspaceSafeFormTrait.php, line 28

Class

WorkspaceSafeFormTrait
Provides helpers for checking whether objects in forms are workspace-safe.

Namespace

Drupal\Core\Entity\Form

Code

protected function isWorkspaceSafeEntity(EntityInterface $entity) : bool {
    if (!\Drupal::hasService('workspaces.information')) {
        return FALSE;
    }
    $is_supported = $this->getWorkspaceInfo()
        ->isEntitySupported($entity);
    $is_ignored = $this->getWorkspaceInfo()
        ->isEntityIgnored($entity);
    return $is_supported || $is_ignored;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.