Пример #1
0
 /**
  * Adds an epic
  *
  * @Route(url="/boards/:board_id/addepic")
  *
  * @param framework\Request $request
  */
 public function runAddEpic(framework\Request $request)
 {
     $this->forward403unless($this->_checkProjectPageAccess('project_planning'));
     $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']);
     try {
         $title = trim($request['title']);
         $shortname = trim($request['shortname']);
         if (!$title) {
             throw new \Exception($this->getI18n()->__('You have to provide a title'));
         }
         if (!$shortname) {
             throw new \Exception($this->getI18n()->__('You have to provide a label'));
         }
         $issue = new \thebuggenie\core\entities\Issue();
         $issue->setTitle($title);
         $issue->setShortname($shortname);
         $issue->setIssuetype($board->getEpicIssuetypeID());
         $issue->setProject($board->getProject());
         $issue->setPostedBy($this->getUser());
         $issue->save();
         return $this->renderJSON(array('issue_details' => $issue->toJSON()));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }