function hook_workflow_permitted_state_transitions_alter in Workflow 7.2
Same name and namespace in other branches
- 8 workflow.api.php \hook_workflow_permitted_state_transitions_alter()
Implements hook_workflow_permitted_state_transitions_alter().
Parameters
array $transitions: An array of allowed transitions from the current state (as provided in $context). They are already filtered by the settings in Admin UI.
array $context: An array of relevant objects. Currently: $context = array( 'entity_type' => $entity_type, 'entity' => $entity, 'field_name' => $field_name, 'force' => $force, 'workflow' => $workflow, 'state' => $current_state, 'user' => $user, 'user_roles' => $roles, // @todo: can be removed in D8, since $user is in. );
This hook allows you to add custom filtering of allowed target states, add new custom states, change labels, etc. It is invoked in WorkflowState::getOptions().
1 invocation of hook_workflow_permitted_state_transitions_alter()
- WorkflowState::getTransitions in includes/
Entity/ WorkflowState.php - Returns the allowed transitions for the current state.
File
- ./
workflow.api.php, line 146 - Hooks provided by the workflow module.
Code
function hook_workflow_permitted_state_transitions_alter(array &$transitions, array $context) {
// This example creates a new custom target state.
$values = array(
// Fixed values for new transition.
'wid' => $context['workflow']->wid,
'sid' => $context['state']->sid,
// Custom values for new transition.
// The ID must be an integer, due to db-table constraints.
'target_sid' => '998',
'label' => 'go to my new fantasy state',
);
$new_transition = new WorkflowConfigTransition($values);
$transitions[] = $new_transition;
}