Пример #1
0
 public function runConfigureWorkflows(TBGRequest $request)
 {
     $this->workflows = TBGWorkflow::getAll();
     if ($request->isPost()) {
         try {
             $workflow_name = $request['workflow_name'];
             $workflow = new TBGWorkflow();
             $workflow->setName($workflow_name);
             $workflow->save();
             $step = new TBGWorkflowStep();
             $step->setName($this->getI18n()->__('New'));
             $step->setWorkflow($workflow);
             $step->save();
             $transition = new TBGWorkflowTransition();
             $transition->setOutgoingStep($step);
             $transition->setName('Issue created');
             $transition->setWorkflow($workflow);
             $transition->setDescription('This is the initial transition for issues using this workflow');
             $transition->save();
             $workflow->setInitialTransition($transition);
             $workflow->save();
             $this->forward(TBGContext::getRouting()->generate('configure_workflow'));
         } catch (Exception $e) {
             $this->error = $e->getMessage();
         }
     }
 }
Пример #2
0
 public function runConfigureWorkflows(TBGRequest $request)
 {
     $this->workflows = TBGWorkflow::getAll();
     if ($request->isMethod(TBGRequest::POST)) {
         try {
             $workflow_name = $request->getParameter('workflow_name');
             $workflow = new TBGWorkflow();
             $workflow->setName($workflow_name);
             $workflow->save();
             $step = new TBGWorkflowStep();
             $step->setName(TBGContext::getI18n()->__('New'));
             $step->setWorkflow($workflow);
             $step->save();
             $this->forward(TBGContext::getRouting()->generate('configure_workflow'));
         } catch (Exception $e) {
             $this->error = $e->getMessage();
         }
     }
 }
Пример #3
0
 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;
 }