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

public
setTemplates(array $templates)

Set the list of templates that can be created

public
array
getTemplates()

Return the list of available templates

public
WorkflowTemplate|null
getNamedTemplate(string $name)

Get a template by name

public
getDefinitionFor(DataObject $dataObject)

Gets the workflow definition for a given dataobject, if there is one

public
getDefinitionByID($object, int $workflowID)

Retrieves a workflow definition by ID for a data object.

public
array
getDefinitionsFor($object)

Retrieves and collates the workflow definitions for a data object, where the first element will be the main workflow definition.

public
getWorkflowFor(mixed $item, bool $includeComplete = false)

Gets the workflow for the given item

public
DataList|null
getWorkflowHistoryFor($item, $limit = null)

Get all the workflow action instances for an item

public
getDefinitions()

Get all the available workflow definitions

public
executeTransition(DataObject $target, int $transitionId)

Given a transition ID, figure out what should happen to the given $subject.

public
startWorkflow(DataObject $object, int $workflowID = null)

Starts the workflow for the given data object, assuming it or a parent has a definition specified.

public
usersWorkflows(Member $user)

Get all the workflows that this user is responsible for

public
userPendingItems(Member $user)

Get items that the passed-in user has awaiting for them to action

public
userSubmittedItems(Member $user)

Get items that the passed-in user has submitted for workflow review

public
defineFromTemplate(WorkflowDefinition $definition, string $templateName)

Generate a workflow definition based on a template

public
reorder(WorkflowDefinition|WorkflowAction $objects, array $newOrder)

Reorders actions within a definition

public
providePermissions()

No description

Details

setTemplates(array $templates)

Set the list of templates that can be created

Parameters

array $templates

array getTemplates()

Return the list of available templates

Return Value

array

WorkflowTemplate|null getNamedTemplate(string $name)

Get a template by name

Parameters

string $name

Return Value

WorkflowTemplate|null

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

Parameters

DataObject $dataObject

getDefinitionByID($object, int $workflowID)

Retrieves a workflow definition by ID for a data object.

@param DataObject $object

Parameters

$object
int $workflowID

@return WorkflowDefinition|null

array getDefinitionsFor($object)

Retrieves and collates the workflow definitions for a data object, where the first element will be the main workflow definition.

Parameters

$object

Return Value

array

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

Parameters

mixed $item
bool $includeComplete

Return Value

WorkflowInstance|null

DataList|null getWorkflowHistoryFor($item, $limit = null)

Get all the workflow action instances for an item

Parameters

$item
$limit

Return Value

DataList|null

DataList getDefinitions()

Get all the available workflow definitions

Return Value

DataList

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.

Parameters

DataObject $target
int $transitionId

Exceptions

Exception

startWorkflow(DataObject $object, int $workflowID = null)

Starts the workflow for the given data object, assuming it or a parent has a definition specified.

Parameters

DataObject $object
int $workflowID

ArrayList usersWorkflows(Member $user)

Get all the workflows that this user is responsible for

Parameters

Member $user

The user to get workflows for

Return Value

ArrayList

The list of workflow instances this user owns

DataList userPendingItems(Member $user)

Get items that the passed-in user has awaiting for them to action

Parameters

Member $user

Return Value

DataList

DataList userSubmittedItems(Member $user)

Get items that the passed-in user has submitted for workflow review

Parameters

Member $user

Return Value

DataList

WorkflowDefinition|null defineFromTemplate(WorkflowDefinition $definition, string $templateName)

Generate a workflow definition based on a template

Parameters

WorkflowDefinition $definition
string $templateName

Return Value

WorkflowDefinition|null

reorder(WorkflowDefinition|WorkflowAction $objects, array $newOrder)

Reorders actions within a definition

Parameters

WorkflowDefinition|WorkflowAction $objects

The objects to be reordered

array $newOrder

An array of IDs of the actions in the order they should be.

providePermissions()

No description