function hook_workflow in Workflow 7.2
Same name and namespace in other branches
- 8 workflow.api.php \hook_workflow()
- 7 workflow.api.php \hook_workflow()
- 7 workflow_admin_ui/workflow_admin_ui.api.php \hook_workflow()
Implements hook_workflow().
NOTE: This hook may reside in the implementing module or in a module.workflow.inc file.
Parameters
string $op: The current workflow operation. E.g., 'transition permitted', 'transition pre' or 'transition post'.
mixed $id: The ID of the current state/transition/workflow.
mixed $new_sid: The state ID of the new state.
object $entity: The entity whose workflow state is changing.
bool $force: The caller indicated that the transition should be forced. (bool). This is only available on the "pre" and "post" calls.
string $entity_type: The entity_type of the entity whose workflow state is changing.
string $field_name: The name of the Workflow Field. Empty in case of Workflow Node. This is used when saving a state change of a Workflow Field.
object $transition: The transition, that contains all of the above. @todo D8: remove all other parameters.
Return value
mixed Only 'transition permitted' expects a boolean result.
6 functions implement hook_workflow()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- WorkflowFeaturesController::export_render_workflow in ./
workflow.features.inc - Renders the provided workflow into export code.
- workflownode_workflow in workflow_node/
workflownode.workflow.inc - Implements hook_workflow().
- workflow_access_workflow in workflow_access/
workflow_access.workflow.inc - Implements hook_workflow().
- workflow_actions_workflow in workflow_actions/
workflow_actions.module - Implements hook_workflow().
- workflow_notify_workflow in workflow_notify/
workflow_notify.module - Implements hook_workflow(). Calls drupal_mail via _workflow_notify() for Workflow Field;
8 invocations of hook_workflow()
- Workflow::delete in includes/
Entity/ Workflow.php - Given a wid, delete the workflow and its data.
- WorkflowConfigTransition::delete in includes/
Entity/ WorkflowConfigTransition.php - Permanently deletes the entity.
- WorkflowState::deactivate in includes/
Entity/ WorkflowState.php - Deactivate a Workflow State, moving existing nodes to a given State.
- WorkflowState::getTransitions in includes/
Entity/ WorkflowState.php - Returns the allowed transitions for the current state.
- WorkflowTransition::execute in includes/
Entity/ WorkflowTransition.php - Execute a transition (change state of a node).
File
- ./
workflow.api.php, line 37 - Hooks provided by the workflow module.
Code
function hook_workflow($op, $id, $new_sid, $entity, $force, $entity_type = '', $field_name = '', $transition = NULL, $user = NULL) {
switch ($op) {
case 'transition permitted':
// This is called in the following situations:
// 1. when building a workflow widget with list of available transitions;
// 2. when executing a transition, just before the 'transition pre';
// 3. when showing a 'revert state' link in a Views display.
// Your module's implementation may return FALSE here and disallow
// the execution, or avoid the presentation of the new State.
// This may be user-dependent.
// As of 7.x-2.3, better use hook_workflow_permitted_state_transitions_alter() in option 1.
// For options 2 and 3, the 'transition pre' gives an alternative.
return TRUE;
case 'transition pre':
// The workflow module does nothing during this operation.
// Implement this hook if you need to change/do something BEFORE anything
// is saved to the database.
// If you return FALSE here, you will veto the transition.
break;
case 'transition post':
// This is called by Workflow Node during update of the state, directly
// after updating {workflow_node}. Workflow Field does not call this,
// since you can call a hook_entity_* event after saving the entity.
// @see https://api.drupal.org/api/drupal/includes%21module.inc/group/hooks/7
break;
case 'transition delete':
// A transition is deleted. Only the first parameter is used.
// $tid = $id;
break;
case 'state delete':
// A state is deleted. Only the first parameter is used.
// $sid = $id;
break;
case 'workflow delete':
// A workflow is deleted. Only the first parameter is used.
// $wid = $id;
break;
}
}