Beispiel #1
0
 public function deleteOutgoingTransitions()
 {
     tables\WorkflowStepTransitions::getTable()->deleteByStepID($this->getID());
 }
 protected function _preDelete()
 {
     tables\WorkflowStepTransitions::getTable()->deleteByTransitionID($this->getID());
 }
Beispiel #3
0
 public function copy($new_name)
 {
     $new_workflow = new \thebuggenie\core\entities\Workflow();
     $new_workflow->setName($new_name);
     $new_workflow->save();
     $step_mapper = array();
     $transition_mapper = array();
     foreach ($this->getSteps() as $key => $step) {
         $this->_steps[$key] = $step->copy($new_workflow);
         $step_mapper[$key] = $this->_steps[$key]->getID();
     }
     foreach ($this->getTransitions() as $key => $transition) {
         $old_id = $transition->getID();
         $this->_transitions[$key] = $transition->copy($new_workflow);
         $transition_mapper[$old_id] = $this->_transitions[$key]->getID();
     }
     tables\WorkflowStepTransitions::getTable()->copyByWorkflowIDs($this->getID(), $new_workflow->getID());
     tables\WorkflowStepTransitions::getTable()->reMapStepIDsByWorkflowID($new_workflow->getID(), $step_mapper);
     tables\WorkflowTransitions::getTable()->reMapByWorkflowID($new_workflow->getID(), $step_mapper);
     tables\WorkflowStepTransitions::getTable()->reMapTransitionIDsByWorkflowID($new_workflow->getID(), $transition_mapper);
     $new_initial_transition = $this->getInitialTransition()->copy($new_workflow);
     $new_initial_transition->setOutgoingStepID($step_mapper[$this->getInitialTransition()->getOutgoingStep()->getID()]);
     $new_initial_transition->save();
     $new_workflow->setInitialTransition($new_initial_transition);
     $new_workflow->save();
     return $new_workflow;
 }