PHP 클래스 raoul2000\workflow\helpers\WorkflowHelper

파일 보기 프로젝트 열기: raoul2000/yii2-workflow 1 사용 예제들

공개 메소드들

메소드 설명
getAllStatusListData ( string $workflowId, IWorkflowSource $workflowSource ) : array Returns an associative array containing all statuses that belong to a workflow.
getNextStatus ( BaseActiveRecord | SimpleWorkflowBehavior $model ) : string Returns the status string of the next valid status from the list of transitions
getNextStatusListData ( BaseActiveRecord $model, boolean $validate = false, boolean $beforeEvents = false, boolean $includeCurrent = false ) : array Returns an associative array containing all statuses that can be reached by model.
getStatusDropDownData ( BaseActiveRecord | SimpleWorkflowBehavior $model ) : array Returns the items and options for a dropDownList All status options are in the list, but invalid transitions are disabled
isValidNextStatus ( BaseActiveRecord | SimpleWorkflowBehavior $model, string $status_id ) : boolean Checks if a given status is a valid transition from the current status
renderLabel ( BaseActiveRecord $model ) : string | null Displays the status for the model passed as argument.

메소드 상세

getAllStatusListData() 공개 정적인 메소드

The array returned is suitable to be used as list data value in (for instance) a dropdown list control. Usage example : assuming model Post has a SimpleWorkflowBehavior the following code displays a dropdown list containing all statuses defined in $post current the workflow :
echo Html::dropDownList(
		'status',
		null,
		WorkflowHelper::getAllStatusListData(
			$post->getWorkflow()->getId(),
			$post->getWorkflowSource()
		)
)
public static getAllStatusListData ( string $workflowId, IWorkflowSource $workflowSource ) : array
$workflowId string
$workflowSource IWorkflowSource
리턴 array

getNextStatus() 공개 정적인 메소드

Returns the status string of the next valid status from the list of transitions
public static getNextStatus ( BaseActiveRecord | SimpleWorkflowBehavior $model ) : string
$model yii\db\BaseActiveRecord | raoul2000\workflow\base\SimpleWorkflowBehavior
리턴 string

getNextStatusListData() 공개 정적인 메소드

Returns an associative array containing all statuses that can be reached by model.
public static getNextStatusListData ( BaseActiveRecord $model, boolean $validate = false, boolean $beforeEvents = false, boolean $includeCurrent = false ) : array
$model yii\db\BaseActiveRecord
$validate boolean when TRUE only those status with successfull attribute validation are included. When FALSE (default) Attribute validation is done performed.
$beforeEvents boolean when TRUE all configured *before* events are fired : only the status that don't invalidate the workflow event are included in the returned array, otherwise no event is fired and all next status are included
$includeCurrent boolean when TRUE the current model status is added to the returned array. When FALSE (default) only next statuses are included
리턴 array

getStatusDropDownData() 공개 정적인 메소드

Example:
$statusDropDownData = WorkflowHelper::getStatusDropDownData($model);
Html
echo Html::dropDownList('status', $model->status, $statusDropdown['items'], ['options' => $statusDropdown['options']]);
ActiveForm
echo $form->field($model, 'status')->dropDownList($statusDropDownData['items'], ['options' => $statusDropDownData['options']]);
public static getStatusDropDownData ( BaseActiveRecord | SimpleWorkflowBehavior $model ) : array
$model yii\db\BaseActiveRecord | raoul2000\workflow\base\SimpleWorkflowBehavior
리턴 array

isValidNextStatus() 공개 정적인 메소드

Checks if a given status is a valid transition from the current status
public static isValidNextStatus ( BaseActiveRecord | SimpleWorkflowBehavior $model, string $status_id ) : boolean
$model yii\db\BaseActiveRecord | raoul2000\workflow\base\SimpleWorkflowBehavior
$status_id string
리턴 boolean

renderLabel() 공개 정적인 메소드

This method assumes that the status includes a metadata value called 'labelTemplate' that contains the HTML template of the rendering status. In this template the string '{label}' will be replaced by the status label. Example :
	'status' => [
		'draft' => [
			'label' => 'Draft',
			'transition' => ['ready' ],
			'metadata' => [
				'labelTemplate' => '{label}'
			]
		],
public static renderLabel ( BaseActiveRecord $model ) : string | null
$model yii\db\BaseActiveRecord
리턴 string | null the HTML rendered status or null if not labelTemplate is found