PHP Класс raoul2000\workflow\source\file\WorkflowFileSource

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.
Наследование: extends yii\base\Object, implements raoul2000\workflow\source\IWorkflowSource
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$definitionCache The workflow definition cache used by this source component can be be specified in one of the following forms : - string : ID of an existing cache component registered in the current Yii::$app. - a configuration array: the array must contain a class element which is treated as the object class, and the rest of the name-value pairs will be used to initialize the corresponding object properties - object : the instance of the cache component By default no cache is used.
$definitionLoader The workflow definition loader used by this source component can be be specified in one of the following forms : - string : ID of an existing workflow definition component registered in the current Yii::$app. - a configuration array: the array must contain a class element which is treated as the object class, and the rest of the name-value pairs will be used to initialize the corresponding object properties - object : the instance of the workflow definition loader Note that in all cases, the workflow definition loader configured here must implement the WorkflowDefinitionLoader interface. If this attribute is not set then a default object of type \raoul2000\workflow\source\file\PhpClassLoader is used.

Открытые методы

Метод Описание
__construct ( array $config = [] ) Constructor method.
addWorkflowDefinition ( string $workflowId, array $definition, boolean $overwrite = false ) : boolean Add a workflow definition array to the collection of workflow definitions handled by this source.
getAllStatuses ( $workflowId ) Returns an array containing all statuses belonging to a workflow.
getClassMap ( ) : string[] Returns the class map array for this Workflow source instance.
getClassMapByType ( string $type ) : string | null Returns the class name that implement the type passed as argument.
getDefinitionCache ( ) : null | yii\caching\Cache Return the workflow definition cache component used by this workflow source or NULL if no cache is used.
getDefinitionLoader ( ) : WorkflowDefinitionLoader Returns the Workflow Definition Loader component.
getStatus ( string $id, mixed $defaultWorkflowId = null ) : Status Returns the status object instance whose id is passed as argument.
getTransition ( $startId, $endId, $defaultWorkflowId = null ) Returns the transition between $startId and $endId statuses.
getTransitions ( $statusId, $defaultWorkflowId = null ) Returns all out going transitions leaving the status whose id is passed as argument.
getWorkflow ( $id ) : Workflow | null Returns the Workflow instance whose id is passed as argument.
getWorkflowDefinition ( string $id ) Loads definition for the workflow whose id is passed as argument.
isValidStatusId ( string $id ) : boolean Checks if the string passed as argument can be used as a status ID.
isValidStatusLocalId ( string $val ) : boolean Checks if the string passed as argument can be used as a status local ID.
isValidWorkflowId ( string $val ) : boolean Checks if the string passed as argument can be used as a workflow ID.
parseStatusId ( string $val, Model | string $helper = null ) : string[] Parses the string $val assuming it is a status id and returns and array containing the workflow ID and status local ID.
validateWorkflowDefinition ( string $wId, array $definition ) : array Validate the workflow definition passed as argument.

Описание методов

__construct() публичный Метод

Constructor method.
public __construct ( array $config = [] )
$config array

addWorkflowDefinition() публичный Метод

This method can be use for instance, by a model that holds the definition of the workflow it is using.
If a workflow with same id already exist in this source, it is overwritten if the last parameter is set to TRUE.
См. также: raoul2000\workflow\base\SimpleWorkflowBehavior::attach()
public addWorkflowDefinition ( string $workflowId, array $definition, boolean $overwrite = false ) : boolean
$workflowId string Id of the workflow
$definition array array containing the workflow definition to process
$overwrite boolean When set to TRUE, the operation will fail if a workflow definition already exists for this ID. Otherwise the existing definition is overwritten.
Результат boolean TRUE if the workflow definition could be added, FALSE otherwise

getAllStatuses() публичный Метод

Returns an array containing all statuses belonging to a workflow.
См. также: raoul2000\workflow\source\IWorkflowSource::getAllStatuses()
public getAllStatuses ( $workflowId )

getClassMap() публичный Метод

Returns the class map array for this Workflow source instance.
public getClassMap ( ) : string[]
Результат string[]

getClassMapByType() публичный Метод

There are 3 built-in types that must have a class name : - self::TYPE_WORKFLOW - self::TYPE_STATUS - self::TYPE_TRANSITION The constructor ensure that if a class map is provided, it include class names for these 3 types. Failure to do so will result in an exception being thrown by the constructor.
public getClassMapByType ( string $type ) : string | null
$type string Type name
Результат string | null | null the class name or NULL if no class name is found forthis type.

getDefinitionCache() публичный Метод

Return the workflow definition cache component used by this workflow source or NULL if no cache is used.
public getDefinitionCache ( ) : null | yii\caching\Cache
Результат null | yii\caching\Cache

getDefinitionLoader() публичный Метод

This component is created the first time this method is invoked (lazy loading).
public getDefinitionLoader ( ) : WorkflowDefinitionLoader
Результат WorkflowDefinitionLoader the workflow definition loader instance

getStatus() публичный Метод

If this status was never loaded before, it is loaded now and stored (cached) for later use. If a $model is provided, it must be a BaseActiveRecord instance with a SimpleWorkflowBehavior attached. This model is used to complete the status ID if the one defined by the $id argument is not complete (e.g. 'draft' instead of 'post/draft').
См. также: raoul2000\workflow\source\IWorkflowSource::getStatus
public getStatus ( string $id, mixed $defaultWorkflowId = null ) : Status
$id string ID of the status to get
$defaultWorkflowId mixed model instance used to resolve the status ID or workflow ID
Результат raoul2000\workflow\base\Status the status instance

getTransition() публичный Метод

Returns the transition between $startId and $endId statuses.
См. также: IWorkflowSource::getTransition()
public getTransition ( $startId, $endId, $defaultWorkflowId = null )

getTransitions() публичный Метод

This method also create instances for the initial status and all statuses that can be reached from it.
См. также: IWorkflowSource::getTransitions()
public getTransitions ( $statusId, $defaultWorkflowId = null )

getWorkflow() публичный Метод

Returns the Workflow instance whose id is passed as argument.
См. также: IWorkflowSource::getTransition()
public getWorkflow ( $id ) : Workflow | null
Результат raoul2000\workflow\base\Workflow | null The workflow instance or NULL if no workflow could be found

getWorkflowDefinition() публичный Метод

The workflow Id passed as argument is used to create the class name of the object that holds the workflow definition.
public getWorkflowDefinition ( string $id )
$id string

isValidStatusId() публичный Метод

This method focuses on the status ID format and not on the fact that it actually refers to an existing status.
См. также: WorkflowFileSource::parseStatusId()
public isValidStatusId ( string $id ) : boolean
$id string the status ID to test
Результат boolean TRUE if $id is a valid status ID, FALSE otherwise.

isValidStatusLocalId() публичный Метод

Checks if the string passed as argument can be used as a status local ID.
public isValidStatusLocalId ( string $val ) : boolean
$val string
Результат boolean

isValidWorkflowId() публичный Метод

A workflow ID is a string that matches self::PATTERN_ID.
public isValidWorkflowId ( string $val ) : boolean
$val string
Результат boolean TRUE if the $val can be used as workflow id, FALSE otherwise

parseStatusId() публичный Метод

If $val does not include the workflow ID part (i.e it is not in formated like "workflowID/statusID") this method uses $helper applying following rules : - if $helper is a string it is considered as the workflow Id - if $helper is an ActiveRecord instance and it is in a workflow, use it. If it is not in a workflow use its default workflow Id.
public parseStatusId ( string $val, Model | string $helper = null ) : string[]
$val string the status ID to parse. If it is not an absolute ID, $helper is used to get the workflow ID.
$helper Model | string workflow Id or ActiveRecord instance used to get the workflow id if not present in $val
Результат string[] array containing the workflow ID in its first index, and the status Local ID in the second

validateWorkflowDefinition() публичный Метод

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 validateWorkflowDefinition ( string $wId, array $definition ) : array
$wId string Id of the workflow to validate
$definition array workflow definition
Результат array list of validation report

Описание свойств

$definitionCache публичное свойство

The workflow definition cache used by this source component can be be specified in one of the following forms : - string : ID of an existing cache component registered in the current Yii::$app. - a configuration array: the array must contain a class element which is treated as the object class, and the rest of the name-value pairs will be used to initialize the corresponding object properties - object : the instance of the cache component By default no cache is used.
public $definitionCache

$definitionLoader публичное свойство

The workflow definition loader used by this source component can be be specified in one of the following forms : - string : ID of an existing workflow definition component registered in the current Yii::$app. - a configuration array: the array must contain a class element which is treated as the object class, and the rest of the name-value pairs will be used to initialize the corresponding object properties - object : the instance of the workflow definition loader Note that in all cases, the workflow definition loader configured here must implement the WorkflowDefinitionLoader interface. If this attribute is not set then a default object of type \raoul2000\workflow\source\file\PhpClassLoader is used.
public $definitionLoader