Skip to content

Commit 7c8c543

Browse files
committed
check for update access as well as workflow transition access on entity
1 parent 44250d3 commit 7c8c543

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Plugin/Action/StateChange.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StateChange extends ActionBase implements ContainerFactoryPluginInterface
4242

4343
/**
4444
* Construct an object of StateChange class.
45-
*
45+
*
4646
*/
4747
public function __construct(array $configuration, $plugin_id, $plugin_definition, ModerationInformationInterface $mod_info, StateTransitionValidationInterface $validation, EntityTypeManagerInterface $entityTypeManager) {
4848
parent::__construct($configuration, $plugin_id, $plugin_definition);
@@ -106,10 +106,12 @@ protected function loadLatestRevision(ContentEntityInterface $entity) {
106106
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
107107
/** @var \Drupal\Core\Entity\ContentEntityInterface $object */
108108
$object = $this->loadLatestRevision($object);
109+
$access = $object->access('update', $account, TRUE);
109110
$from = $this->entityTypeManager->getStorage('moderation_state')->load($object->get('moderation_state')->target_id);
110111
$to = $this->entityTypeManager->getStorage('moderation_state')->load($this->pluginDefinition['state']);
111112

112-
$result = AccessResult::allowedIf($this->validation->userMayTransition($from, $to, $account));
113+
$result = AccessResult::allowedIf($this->validation->userMayTransition($from, $to, $account))
114+
->andIf($access);
113115

114116
return $return_as_object ? $result : $result->isAllowed();
115117
}

0 commit comments

Comments
 (0)