function hook_workflow_operations in Workflow 8
Same name and namespace in other branches
- 7.2 workflow_admin_ui/workflow_admin_ui.api.php \hook_workflow_operations()
Implements hook_workflow_operations().
Adds extra operations to ListBuilders:
- Workflow, WorkflowState, WorkflowTransition;
Parameters
string $op: 'top_actions': Allow modules to insert their own front page action links. 'operations': Allow modules to insert their own workflow operations. 'workflow': Allow modules to insert workflow operations. 'state': Allow modules to insert state operations.
\Drupal\Core\Entity\EntityInterface|null $entity: The current workflow/state/transition object.
Return value
array The new actions, to be added to the entity list.
1 call to hook_workflow_operations()
- workflow_devel_workflow_operations in modules/
workflow_devel/ workflow_devel.module - @inheritdoc
2 functions implement hook_workflow_operations()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- workflow_access_workflow_operations in modules/
workflow_access/ workflow_access.module - @inheritdoc
- workflow_devel_workflow_operations in modules/
workflow_devel/ workflow_devel.module - @inheritdoc
2 invocations of hook_workflow_operations()
- WorkflowListBuilder::getDefaultOperations in src/
WorkflowListBuilder.php - Gets this list's default operations.
- WorkflowStateListBuilder::getDefaultOperations in src/
WorkflowStateListBuilder.php - Gets this list's default operations.
File
- ./
workflow.api.php, line 33 - Hooks provided by the workflow module.
Code
function hook_workflow_operations($op, EntityInterface $entity = NULL) {
$operations = [];
switch ($op) {
case 'top_actions':
// As of D8, below hook_workflow_operations is removed, in favour of core hooks.
// @see workflow.links.action.yml for an example top action.
return $operations;
case 'operations':
break;
case 'workflow':
// This example adds an operation to the 'operations column' of the Workflow List.
/** @var \Drupal\workflow\Entity\Workflow $workflow */
$workflow = $entity;
$alt = t('Control content access for @wf', [
'@wf' => $workflow
->label(),
]);
$attributes = [
'alt' => $alt,
'title' => $alt,
];
$operations['workflow_access_form'] = [
'title' => t('Access'),
'weight' => 50,
'url' => Url::fromRoute('entity.workflow_type.access_form', [
'workflow_type' => $workflow
->id(),
]),
'query' => \Drupal::destination()
->getAsArray(),
];
return $operations;
case 'state':
/** @var \Drupal\workflow\Entity\WorkflowState $state */
$state = $entity;
break;
case 'workflow_transition':
// As of D8, below hook_workflow_operations is removed, in favour of core hooks.
// @see EntityListBuilder::getOperations, workflow_operations, workflow.api.php.
// Your module may add operations to the Entity list.
/** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $transition */
$transition = $entity;
break;
default:
break;
}
return $operations;
}