class WorkflowTemplate (View source)

A class that wraps around an array description of a workflow

array( 'Step Name' = array( 'type' => class name 'transitions' => array( 'transition name' => 'target step', 'next name' => 'other step' ) ), 'Next Step' = array(

), )

This can be defined in config yml as follows

SilverStripe\Core\Injector\Injector: SimpleReviewApprove: class: Symbiote\AdvancedWorkflow\Templates\WorkflowTemplate constructor:

  • Review and Approve
  • Description of the workflow template
  • 0.1 (version number) properties: structure: Apply for approval: type: AssignUsersToWorkflowAction transitions: notify: Notify users Notify users: type: NotifyUsersWorkflowAction transitions: approval: Approval Approval: type: SimpleApprovalWorkflowAction transitions: Approve: Publish Reject: Reject Publish: type: PublishItemWorkflowAction Reject: type: CancelWorkflowAction Symbiote\AdvancedWorkflow\Services\WorkflowService: properties: templates:
    • %$SimpleReviewApprove

When updating a template, there's a few things that can be done to assist the system when changing things around

  1. Update the 'version' number

Properties

protected $name
protected $description
protected $version
protected $remindDays
protected $sort
protected array $structure

An array representation of the structure of this workflow template

Methods

public
__construct($name, $description = '', $version = '0.0', $remindDays = 0, $sort = 0)

No description

public
string
getName()

No description

public
string
getVersion()

No description

public
string
getDescription()

No description

public
int
getRemindDays()

No description

public
int
getSort()

No description

public
setStructure(array $structure)

Set the structure for this template

public
array
createRelations($definition = null)

Creates the relevant data objects for this structure, returning an array of actions in the order they've been created

protected
WorkflowAction
createAction(string $name, $actionTemplate, WorkflowDefinition|null $definition = null)

Create a workflow action based on a template

protected
void
createUsers(array $users, WorkflowDefinition $definition, bool $clear = false)

Create a WorkflowDefinition->Users relation based on template data. But only if the related groups from the export, can be foud in the target environment's DB.

protected
void
createGroups(array $groups, WorkflowDefinition $definition, bool $clear = false)

Create a WorkflowDefinition->Groups relation based on template data, But only if the related groups from the export, can be foud in the target environment's DB.

protected
array
updateActionTransitions(array $actionTemplate, WorkflowAction $action)

Update the transitions for a given action

public
updateDefinition(WorkflowDefinition $definition)

Update a workflow definition

protected
void
addManyManyToObject(object $object, array $source, bool $clear = false)

Given an object, first check it has a ManyMany relation on it and add() Member and Group relations as required.

Details

__construct($name, $description = '', $version = '0.0', $remindDays = 0, $sort = 0)

No description

Parameters

$name
$description
$version
$remindDays
$sort

string getName()

No description

Return Value

string

string getVersion()

No description

Return Value

string

string getDescription()

No description

Return Value

string

int getRemindDays()

No description

Return Value

int

int getSort()

No description

Return Value

int

setStructure(array $structure)

Set the structure for this template

Parameters

array $structure

array createRelations($definition = null)

Creates the relevant data objects for this structure, returning an array of actions in the order they've been created

Parameters

$definition

Return Value

array

protected WorkflowAction createAction(string $name, $actionTemplate, WorkflowDefinition|null $definition = null)

Create a workflow action based on a template

Parameters

string $name
$actionTemplate
WorkflowDefinition|null $definition

Return Value

WorkflowAction

Exceptions

Exception

protected void createUsers(array $users, WorkflowDefinition $definition, bool $clear = false)

Create a WorkflowDefinition->Users relation based on template data. But only if the related groups from the export, can be foud in the target environment's DB.

Note: The template gives us a Member Email to work with rather than an ID as it's arguably more likely that Member Emails will be the same between environments than their IDs.

Parameters

array $users
WorkflowDefinition $definition
bool $clear

Return Value

void

protected void createGroups(array $groups, WorkflowDefinition $definition, bool $clear = false)

Create a WorkflowDefinition->Groups relation based on template data, But only if the related groups from the export, can be foud in the target environment's DB.

Note: The template gives us a Group Title to work with rther than an ID as it's arguably more likely that Group titles will be the same between environments than their IDs.

Parameters

array $groups
WorkflowDefinition $definition
bool $clear

Return Value

void

protected array updateActionTransitions(array $actionTemplate, WorkflowAction $action)

Update the transitions for a given action

Parameters

array $actionTemplate
WorkflowAction $action

Return Value

array

updateDefinition(WorkflowDefinition $definition)

Update a workflow definition

Parameters

WorkflowDefinition $definition

The definition to update

protected void addManyManyToObject(object $object, array $source, bool $clear = false)

Given an object, first check it has a ManyMany relation on it and add() Member and Group relations as required.

Parameters

object $object

(e.g. WorkflowDefinition, WorkflowAction, WorkflowTransition)

array $source

Usually data taken from a YAML template

bool $clear

Lose/keep Group/Member relations on $object (useful for reloading/refreshing definition)

Return Value

void