WorkflowService
class WorkflowService implements PermissionProvider (View source)
A central point for interacting with workflows
Properties
protected | array | $templates | An array of templates that we can create from |
Methods
Gets the workflow definition for a given dataobject, if there is one
Retrieves a workflow definition by ID for a data object.
Retrieves and collates the workflow definitions for a data object, where the first element will be the main workflow definition.
Gets the workflow for the given item
Get all the workflow action instances for an item
Given a transition ID, figure out what should happen to the given $subject.
Starts the workflow for the given data object, assuming it or a parent has a definition specified.
Get items that the passed-in user has submitted for workflow review
Generate a workflow definition based on a template
Reorders actions within a definition
Details
setTemplates(array $templates)
Set the list of templates that can be created
array
getTemplates()
Return the list of available templates
WorkflowTemplate|null
getNamedTemplate(string $name)
Get a template by name
getDefinitionFor(DataObject $dataObject)
Gets the workflow definition for a given dataobject, if there is one
Will recursively query parent elements until it finds one, if available
getDefinitionByID($object, int $workflowID)
Retrieves a workflow definition by ID for a data object.
@param DataObject $object
array
getDefinitionsFor($object)
Retrieves and collates the workflow definitions for a data object, where the first element will be the main workflow definition.
WorkflowInstance|null
getWorkflowFor(mixed $item, bool $includeComplete = false)
Gets the workflow for the given item
The item can be
a data object in which case the ActiveWorkflow will be returned, an action, in which case the Workflow will be returned an integer, in which case the workflow with that ID will be returned
WorkflowActionInstance>|void
getWorkflowHistoryFor($item, $limit = null)
Get all the workflow action instances for an item
WorkflowDefinition>
getDefinitions()
Get all the available workflow definitions
executeTransition(DataObject $target, int $transitionId)
Given a transition ID, figure out what should happen to the given $subject.
In the normal case, this will load the current workflow instance for the object and then transition as expected. However, in some cases (eg to start the workflow) it is necessary to instead create a new instance.
startWorkflow(DataObject $object, int $workflowID = null)
Starts the workflow for the given data object, assuming it or a parent has a definition specified.
WorkflowInstance>
usersWorkflows(Member $user)
Get all the workflows that this user is responsible for
WorkflowInstance>
userPendingItems(Member $user)
Get items that the passed-in user has awaiting for them to action
WorkflowInstance>
userSubmittedItems(Member $user)
Get items that the passed-in user has submitted for workflow review
WorkflowDefinition|null
defineFromTemplate(WorkflowDefinition $definition, string $templateName)
Generate a workflow definition based on a template
reorder(WorkflowDefinition|WorkflowAction $objects, array $newOrder)
Reorders actions within a definition
providePermissions()
No description