Example #1
0
 /**
  * Get steps which can be a target.
  *
  * @param \DataContainer $dataContainer Data container driver.
  *
  * @return array
  */
 public function getStepsTo($dataContainer)
 {
     $steps = array();
     $collection = StepModel::findBy(['pid=?'], [$dataContainer->activeRecord->pid], ['order' => 'name']);
     if ($collection) {
         while ($collection->next()) {
             $steps[$collection->id] = $collection->label;
             if ($collection->final) {
                 $steps[$collection->id] .= ' [final]';
             }
         }
     }
     return $steps;
 }
 /**
  * Create the steps.
  *
  * @param Workflow $workflow The current workflow.
  *
  * @return void
  */
 private function createSteps(Workflow $workflow)
 {
     $collection = StepModel::findByWorkflow($workflow->getConfigValue('id'));
     if (!$collection) {
         return;
     }
     while ($collection->next()) {
         /** @var StepModel $model */
         $model = $collection->current();
         $step = new Step($model->name, $model->label, array_merge($collection->row(), array(Definition::SOURCE => Definition::SOURCE_DATABASE)));
         $step->setFinal($model->final);
         if ($model->limitPermission) {
             $step->setPermission(Permission::fromString($model->permission));
         }
         $workflow->addStep($step);
         $event = new CreateStepEvent($workflow, $step);
         $this->getServiceContainer()->getEventDispatcher()->dispatch($event::NAME, $event);
         $this->steps[$model->id] = $step;
     }
 }
Example #3
0
 /**
  * Get steps form database.
  *
  * @param int  $parentId    The parent id.
  * @param bool $filterFinal If true only steps which are not final are loaded.
  *
  * @return array
  */
 private function getSteps($parentId, $filterFinal = false)
 {
     $steps = array();
     if ($filterFinal) {
         $collection = StepModel::findBy(['pid=?', 'final=?'], [$parentId, ''], ['order' => 'name']);
     } else {
         $collection = StepModel::findBy(['pid=?'], [$parentId], ['order' => 'name']);
     }
     if ($collection) {
         while ($collection->next()) {
             $steps[$collection->id] = $collection->label;
             if ($collection->final) {
                 $steps[$collection->id] .= ' [final]';
             }
         }
     }
     return $steps;
 }