You are here

public function UnpublishAction::access in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php \Drupal\Core\Action\Plugin\Action\UnpublishAction::access()
  2. 9 core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php \Drupal\Core\Action\Plugin\Action\UnpublishAction::access()

File

core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php, line 28

Class

UnpublishAction
Unpublishes an entity.

Namespace

Drupal\Core\Action\Plugin\Action

Code

public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
  $key = $object
    ->getEntityType()
    ->getKey('published');

  /** @var \Drupal\Core\Entity\EntityInterface $object */
  $result = $object
    ->access('update', $account, TRUE)
    ->andIf($object->{$key}
    ->access('edit', $account, TRUE));
  return $return_as_object ? $result : $result
    ->isAllowed();
}