X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fworkflows%2Fsrc%2FWorkflowAccessControlHandler.php;h=1e0456cf6dfa6601b5f6b386911add90bcb161ee;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=156f0091ccf85331c09eba6b8ff8db4339ae271e;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/workflows/src/WorkflowAccessControlHandler.php b/web/core/modules/workflows/src/WorkflowAccessControlHandler.php index 156f0091c..1e0456cf6 100644 --- a/web/core/modules/workflows/src/WorkflowAccessControlHandler.php +++ b/web/core/modules/workflows/src/WorkflowAccessControlHandler.php @@ -12,13 +12,9 @@ use Drupal\Core\Access\AccessResult; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Access controller for the Moderation State entity. + * Access controller for the Workflow entity. * * @see \Drupal\workflows\Entity\Workflow. - * - * @internal - * The workflow system is currently experimental and should only be leveraged - * by experimental modules and development releases of contributed modules. */ class WorkflowAccessControlHandler extends EntityAccessControlHandler implements EntityHandlerInterface { @@ -62,15 +58,13 @@ class WorkflowAccessControlHandler extends EntityAccessControlHandler implements list(, $state_id) = explode(':', $operation, 2); // Deleting a state is editing a workflow, but also we should forbid // access if there is only one state. - $admin_access = AccessResult::allowedIf(count($entity->getStates()) > 1) + return AccessResult::allowedIf(count($entity->getTypePlugin()->getStates()) > 1) ->andIf(parent::checkAccess($entity, 'edit', $account)) ->andIf(AccessResult::allowedIf(!in_array($state_id, $workflow_type->getRequiredStates(), TRUE))) ->addCacheableDependency($entity); } - else { - $admin_access = parent::checkAccess($entity, $operation, $account); - } - return $workflow_type->checkWorkflowAccess($entity, $operation, $account)->orIf($admin_access); + + return parent::checkAccess($entity, $operation, $account); } /** @@ -81,7 +75,9 @@ class WorkflowAccessControlHandler extends EntityAccessControlHandler implements $admin_access = parent::checkCreateAccess($account, $context, $entity_bundle); // Allow access if there is at least one workflow type. Since workflow types // are provided by modules this is cacheable until extensions change. - return $admin_access->andIf(AccessResult::allowedIf($workflow_types_count > 0))->addCacheTags(['config:core.extension']); + return $admin_access + ->andIf(AccessResult::allowedIf($workflow_types_count > 0)) + ->addCacheTags(['workflow_type_plugins']); } }