public function deleteOutgoingTransitions() { TBGWorkflowStepTransitionsTable::getTable()->deleteByStepID($this->getID()); }
public function _preDelete() { TBGWorkflowStepTransitionsTable::getTable()->deleteByTransitionID($this->getID()); }
public function copy($new_name) { $new_workflow = new TBGWorkflow(); $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(); } TBGWorkflowStepTransitionsTable::getTable()->copyByWorkflowIDs($this->getID(), $new_workflow->getID()); TBGWorkflowStepTransitionsTable::getTable()->reMapStepIDsByWorkflowID($new_workflow->getID(), $step_mapper); TBGWorkflowTransitionsTable::getTable()->reMapByWorkflowID($new_workflow->getID(), $step_mapper); TBGWorkflowStepTransitionsTable::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; }