raoul2000\workflow\helpers\WorkflowHelper::getAllStatusListData PHP Метод

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
    public static function getAllStatusListData($workflowId, $workflowSource)
    {
        $listData = [];
        $statuses = $workflowSource->getAllStatuses($workflowId);
        foreach ($statuses as $statusId => $statusInstance) {
            $listData[$statusId] = $statusInstance->getLabel();
        }
        return $listData;
    }

Usage Example

 public function testGetStatusDropDownData()
 {
     $model = new Item04();
     $model->enterWorkflow();
     $ar = WorkflowHelper::GetStatusDropDownData($model);
     $listData = WorkflowHelper::getAllStatusListData($model->getWorkflow()->getId(), $model->getWorkflowSource());
     codecept_debug($ar);
     $expected = ['Item04Workflow/A' => 'Entry', 'Item04Workflow/B' => 'Published'];
     $this->assertTrue(is_array($ar));
     $this->assertTrue(isset($ar['items']) && is_array($ar['items']));
     $this->assertTrue(isset($ar['options']) && is_array($ar['options']));
     $this->assertEquals(2, count($ar));
     foreach ($listData as $status => $label) {
         $this->assertTrue(array_key_exists($status, $ar['items']));
     }
     $this->assertTrue($ar['options']['Item04Workflow/C']['disabled']);
     $this->assertTrue($ar['options']['Item04Workflow/D']['disabled']);
 }
All Usage Examples Of raoul2000\workflow\helpers\WorkflowHelper::getAllStatusListData