예제 #1
0
 /**
  * Returns an associative array containing all statuses that belong to a workflow.
  * 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 ActiveWorkflowBehavior 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->getWorkflowFactory()
  * 		)
  * )
  * 
  * @param string $workflowId
  * @param IWorkflowItemFactory $workflowFactory
  * @param Component|ActiveWorkflowBehavior $model
  *
  * @return Array
  */
 public static function getAllStatusListData($workflowId, $workflowFactory, $model)
 {
     $listData = [];
     $statuses = $workflowFactory->getAllStatuses($workflowId, $model);
     /**
      * @var mixed $statusId
      * @var Status $statusInstance
      */
     foreach ($statuses as $statusId => $statusInstance) {
         $listData[$statusId] = $statusInstance->getLabel();
     }
     return $listData;
 }
 /**
  *
  * @param array $ids
  * @param string $workflowId
  * @param IWorkflowItemFactory $factory
  * @param Component|ActiveWorkflowBehavior $model
  * @return array
  */
 private function normalizeStatusIds($ids, $workflowId, $factory, $model)
 {
     $normalizedIds = [];
     foreach ($ids as $id) {
         $pieces = $factory->parseWorkflowStatus($id, $workflowId, $model);
         $normalizedIds[] = $pieces[0] . ArrayWorkflowItemFactory::SEPARATOR_STATUS_NAME . $pieces[1];
     }
     return $normalizedIds;
 }