Example #1
0
 /**
  * Add or edit a project group.
  * @param null $groupId
  * @return void|b8\Http\Response\RedirectResponse
  */
 public function edit($groupId = null)
 {
     $this->requireAdmin();
     if (!is_null($groupId)) {
         $group = $this->groupStore->getById($groupId);
     } else {
         $group = new ProjectGroup();
     }
     if ($this->request->getMethod() == 'POST') {
         $group->setTitle($this->getParam('title'));
         $this->groupStore->save($group);
         $response = new b8\Http\Response\RedirectResponse();
         $response->setHeader('Location', PHPCI_URL . 'group');
         return $response;
     }
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'group/edit' . (!is_null($groupId) ? '/' . $groupId : ''));
     $title = new Form\Element\Text('title');
     $title->setContainerClass('form-group');
     $title->setClass('form-control');
     $title->setLabel('Group Title');
     $title->setValue($group->getTitle());
     $submit = new Form\Element\Submit();
     $submit->setValue('Save Group');
     $form->addField($title);
     $form->addField($submit);
     $this->view->form = $form;
 }
Example #2
0
 /**
  * Set Group - Accepts a ProjectGroup model.
  * 
  * @param $value \PHPCI\Model\ProjectGroup
  */
 public function setGroupObject(\PHPCI\Model\ProjectGroup $value)
 {
     return $this->setGroupId($value->getId());
 }