You are here

public function WorkflowDeleteAccessCheck::access in Drupal 8

Checks access for operations of workflow states and transitions.

The value of '_workflow_access' is used to check to kind of access that should be applied to a route in the context of a workflow and a state or transition. States and transitions can individually have access control applied to them for 'add', 'update' and 'delete'. By default workflows will use the admin permission 'administer workflows' for all of these operations, except for delete-state which checks there is at least one state, a state does not have data and it's not a required state.

For the update and delete operations, a workflow and a state or transition is required in the route for the access check to be applied. For the "add" operation, only a workflow is required. The '_workflow_access' requirement translates into access checks on the workflow entity type in the formats:

?>
<?php"$operation-state:$state_id"?><?php
?>
<?php"$operation-transition:$transition_id"?><?php

For example the following route definition with the path "/test-workflow/foo-state/delete" the 'delete-state:foo-state' operation will be checked:


pattern: '/{workflow}/{workflow_state}/delete'
requirements:
  _workflow_access: 'delete-state'

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The parametrized route

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

\Drupal\Core\Access\AccessResultInterface An access result.

Throws

\Exception Throws an exception when a route is defined with an invalid operation.

Overrides WorkflowStateTransitionOperationsAccessCheck::access

File

core/modules/workflows/src/WorkflowDeleteAccessCheck.php, line 35

Class

WorkflowDeleteAccessCheck
Provides a access checker for deleting a workflow state.

Namespace

Drupal\workflows

Code

public function access(RouteMatchInterface $route_match, AccountInterface $account) {
  @trigger_error('Using the _workflow_state_delete_access check is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0, use _workflow_access instead. As an internal API _workflow_state_delete_access may also be removed in a minor release.', E_USER_DEPRECATED);
  return parent::access($route_match, $account);
}