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
__construct()

No description

public
setTemplates(type $templates)

Set the list of templates that can be created

public
type
getTemplates()

Return the list of available templates

public
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
workflow
getDefinitionByID($object, $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, $includeComplete = false)

Gets the workflow for the given item

public
DataObjectSet
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, WorkflowDefinition $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

__construct()

No description

setTemplates(type $templates)

Set the list of templates that can be created

Parameters

type $templates

type getTemplates()

Return the list of available templates

Return Value

type

WorkflowTemplate getNamedTemplate(string $name)

Get a template by name

Parameters

string $name

Return Value

WorkflowTemplate

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

workflow getDefinitionByID($object, $workflowID)

Retrieves a workflow definition by ID for a data object.

Parameters

$object
$workflowID

Return Value

workflow definition

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 getWorkflowFor(mixed $item, $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
$includeComplete

Return Value

WorkflowInstance

DataObjectSet getWorkflowHistoryFor($item, $limit = null)

Get all the workflow action instances for an item

Parameters

$item
$limit

Return Value

DataObjectSet

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

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

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

Parameters

DataObject $object

The object to start a workflow against

WorkflowDefinition $workflowID

The WorkflowDefinition to trigger a new workflow instance of, or its ID

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 $userInstances

DataList userSubmittedItems(Member $user)

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

Parameters

Member $user

Return Value

DataList $userInstances

defineFromTemplate(WorkflowDefinition $definition, string $templateName)

Generate a workflow definition based on a template

Parameters

WorkflowDefinition $definition
string $templateName

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