/** * Executes the transition. * After a successful transition this function will not work again for this object. * * @return bool */ public function doTransition() { // do not transition if this was already executed if ($this->transitionCompleted) { return TRUE; } // only execute transition if id is given if (empty($this->transition->getId())) { return FALSE; } // issue of this transition must be set and persistent if (empty($this->issue) || !$this->issue->isPersistent()) { return FALSE; } // this transition must be the issue's active one if ($this->issue->getActiveTransition() !== $this) { return FALSE; } // get transition's issue's key or id if (!empty($this->issue->getKey())) { $issue_identifier = $this->issue->getKey(); } elseif (!empty($this->issue->getId())) { $issue_identifier = $this->issue->getId(); } else { return FALSE; } // get currently available transitions for this issue in this status $transitions = Transition::getTransitions($this->issue); if (empty($transitions[$this->transition->getId()])) { return FALSE; } $this->createDiffObject(true); $path = 'issue/' . $issue_identifier . '/transitions'; $response = $this->issue->getCommunicationService()->post($path, $this->getDiffObject(), 204); if ($response === FALSE) { return FALSE; } // update associated issue $this->issue->fields->status = $transitions[$this->transition->getId()]; $this->transitionCompleted = TRUE; $this->issue->deleteActiveTransition($this); return TRUE; }