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
파일 보기 프로젝트 열기: raoul2000/yii2-workflow 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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