Class WorkflowFileSource
This class provides workflow objects (Workflow, Status, Transitions) to the SimpleWorkflowBehavior behavior. The task of loading the workflow definition file, and turns it content into a normalized array, is delegated to a [[WorkflowDefinitionLoader]] instance. The definition loader can be initialized through the [[definitionLoader]] attribute.
- yii\base\Object
- raoul2000\workflow\source\file\WorkflowFileSource implements raoul2000\workflow\source\IWorkflowSource
Methods summary
public
|
|
public
|
#
getDefinitionLoader( )
Returns the Workflow Definition Loader component. This component is created the first time this method is invoked (lazy loading). |
public
null|yii\caching\Cache
|
#
getDefinitionCache( )
Return the workflow definition cache component used by this workflow source or NULL if no cache is used. |
public
|
#
getStatus( string $id, mixed $defaultWorkflowId = null )
Returns the status object instance whose id is passed as argument. If this status was never loaded before, it is loaded now and stored (cached) for later use. |
public
|
#
getTransitions( mixed $statusId, $defaultWorkflowId = null )
Returns all out going transitions leaving the status whose id is passed as argument. This method also create instances for the initial status and all statuses that can be reached from it. |
public
|
#
getTransition( mixed $startId, mixed $endId, mixed $defaultWorkflowId = null )
Returns the transition between $startId and $endId statuses. |
public
|
|
public
|
#
getWorkflowDefinition( string $id )
Loads definition for the workflow whose id is passed as argument. |
public
string[]
|
|
public
string
|
#
getClassMapByType( string $type )
Returns the class name that implement the type passed as argument. There are 3 built-in types that must have a class name : |
public
string[]
|
#
parseStatusId( string $val, Model|string $helper = null )
Parses the string $val assuming it is a status id and returns and array containing the workflow ID and status local ID. |
public
boolean
|
|
public
boolean
|
#
isValidWorkflowId( string $val )
Checks if the string passed as argument can be used as a workflow ID. |
public
boolean
|
#
isValidStatusLocalId( string $val )
Checks if the string passed as argument can be used as a status local ID. |
public
boolean
|
#
addWorkflowDefinition( string $workflowId, array $definition, boolean $overwrite = false )
Add a workflow definition array to the collection of workflow definitions handled by this source.
This method can be use for instance, by a model that holds the definition of the workflow it is
using. |
public
array
|
#
validateWorkflowDefinition( string $wId, array $definition )
Validate the workflow definition passed as argument. The workflow definition array format is the one used internally by this class, and that should have been provided by the configured workflow definition provider component. |
public
|
#
getAllStatuses( string $workflowId )
Returns an array containing all statuses belonging to a workflow. |
Constants summary
string |
PATTERN_ID
The regular expression used to validate status and workflow Ids. |
#
'/^[a-zA-Z]+[[:alnum:]-]*$/'
|
string |
SEPARATOR_STATUS_NAME
The separator used to create a status id by concatenating the workflow id and the status local id (e.g. post/draft). |
#
'/'
|
string |
KEY_NODES
Name of the array key for status list definition |
#
'status'
|
string |
KEY_EDGES
Name of the key for transition list definition |
#
'transition'
|
string |
KEY_METADATA
Name of the key for metadata definition |
#
'metadata'
|
string |
DEFAULT_WDLOADER_CLASS
Name of the parser class that is used by default |
#
'\raoul2000\workflow\source\file\PhpClassLoader'
|
string |
TYPE_STATUS
array key for status class in class map |
#
'status'
|
string |
TYPE_TRANSITION
array key for transition class in class map |
#
'transition'
|
string |
TYPE_WORKFLOW
array key for workflow class in class map |
#
'workflow'
|
Properties summary
public
string|array| |
$definitionLoader
The workflow definition loader used by this source component can be be specified in one of the following forms :
Note that in all cases, the workflow definition loader configured here must implement the
If this attribute is not set then a default object of type |
|
public
string|array|yii\caching\Cache
|
$definitionCache
The workflow definition cache used by this source component can be be specified in one of the following forms :
By default no cache is used. |