コード例 #1
0
 public function indexAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     $action = $this->params()->fromQuery('action', '');
     if ($action == 'delete' && $id > 0) {
         $this->roleTable()->deleteRole($id);
         $this->flashMessenger()->addInfoMessage('Delete successful!');
         return $this->redirect()->toRoute("role");
     }
     $parentRole = new Role();
     $edit = false;
     if ($id > 0) {
         $role = $this->roleTable()->getRole($id);
         if ($role->getParentId()) {
             $parentRole = $this->roleTable()->getRole($role->getParentId());
         }
         $edit = true;
     } else {
         $role = new Role();
     }
     $roles = $this->roleTable()->getChildren();
     $helper = new RoleHelper();
     $form = $helper->getForm();
     if ($action == 'clone') {
         $edit = false;
         $id = 0;
         $role->setRoleId(0);
     }
     $form->bind($role);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->roleTable()->saveRole($role);
             $this->flashMessenger()->addSuccessMessage('Save successful!');
             return $this->redirect()->toRoute("role");
         }
     }
     return new ViewModel(array('id' => $id, 'roles' => $roles, 'form' => $form, 'isEdit' => $edit, 'parent' => $parentRole));
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function getUpdatedAt()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUpdatedAt', array());
     return parent::getUpdatedAt();
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function getPermissions()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPermissions', array());
     return parent::getPermissions();
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function setParent(\Application\Entity\Role $parent)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setParent', array($parent));
     return parent::setParent($parent);
 }
コード例 #5
0
 /**
  * @param Role $role
  * @return Role
  */
 public function saveRole(Role $role)
 {
     $id = $role->getRoleId();
     $data = $role->getArrayCopy();
     if ($id > 0) {
         $this->update($data, array('roleId' => $id));
     } else {
         unset($data['roleId']);
         $this->insert($data);
     }
     if (!$role->getRoleId()) {
         $role->setRoleId($this->getLastInsertValue());
     }
     return $role;
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  */
 public function getDescription()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDescription', array());
     return parent::getDescription();
 }