function UnpublishAction::access

Same name in other branches
  1. 9 core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php \Drupal\Core\Action\Plugin\Action\UnpublishAction::access()
  2. 8.9.x core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php \Drupal\Core\Action\Plugin\Action\UnpublishAction::access()
  3. 10 core/lib/Drupal/Core/Action/Plugin/Action/UnpublishAction.php \Drupal\Core\Action\Plugin\Action\UnpublishAction::access()

Overrides ActionInterface::access

1 call to UnpublishAction::access()
ModerationOptOutUnpublish::access in core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php
1 method overrides UnpublishAction::access()
ModerationOptOutUnpublish::access in core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php

File

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

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();
}

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