class WorkflowCustomAccessType in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/WorkflowCustomAccessType.php \Drupal\workflow_type_test\Plugin\WorkflowType\WorkflowCustomAccessType
- 9 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/WorkflowCustomAccessType.php \Drupal\workflow_type_test\Plugin\WorkflowType\WorkflowCustomAccessType
A test workflow with custom state/transition access rules applied.
Plugin annotation
@WorkflowType(
id = "workflow_custom_access_type",
label = @Translation("Workflow Custom Access Type Test"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\workflows\Plugin\WorkflowTypeBase implements WorkflowTypeInterface uses PluginWithFormsTrait
- class \Drupal\workflow_type_test\Plugin\WorkflowType\WorkflowCustomAccessType
- class \Drupal\workflows\Plugin\WorkflowTypeBase implements WorkflowTypeInterface uses PluginWithFormsTrait
Expanded class hierarchy of WorkflowCustomAccessType
1 file declares its use of WorkflowCustomAccessType
- workflow_type_test.module in core/
modules/ workflows/ tests/ modules/ workflow_type_test/ workflow_type_test.module - Module file for workflow_type_test.
File
- core/
modules/ workflows/ tests/ modules/ workflow_type_test/ src/ Plugin/ WorkflowType/ WorkflowCustomAccessType.php, line 18
Namespace
Drupal\workflow_type_test\Plugin\WorkflowTypeView source
class WorkflowCustomAccessType extends WorkflowTypeBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'states' => [
'cannot_update' => [
'label' => 'Cannot Update State',
'weight' => 0,
],
'cannot_delete' => [
'label' => 'Cannot Delete State',
'weight' => 0,
],
],
'transitions' => [
'cannot_update' => [
'label' => 'Cannot Update Transition',
'to' => 'cannot_update',
'weight' => 0,
'from' => [
'cannot_update',
],
],
'cannot_delete' => [
'label' => 'Cannot Delete Transition',
'to' => 'cannot_delete',
'weight' => 1,
'from' => [
'cannot_delete',
],
],
],
];
}
/**
* Implements hook_ENTITY_TYPE_access().
*
* @see workflow_type_test_workflow_access
*/
public static function workflowAccess(WorkflowInterface $entity, $operation, AccountInterface $account) {
$forbidden_operations = \Drupal::state()
->get('workflow_type_test_forbidden_operations', []);
return in_array($operation, $forbidden_operations, TRUE) ? AccessResult::forbidden() : AccessResult::neutral();
}
}