コード例 #1
0
ファイル: PageController.php プロジェクト: Rademade/MedOptima
 public function systemAddAction()
 {
     if (!$this->_user->getRole()->isProgrammer()) {
         $this->__redirectToLogin();
     } else {
         parent::addAction();
         if ($this->getRequest()->isPost()) {
             try {
                 $data = (object) $this->getRequest()->getPost();
                 $this->_entity = Application_Model_Page::createSimplePage();
                 $this->_setData($data);
                 $route = RM_Routing::getByUrl($data->url);
                 if (!$route instanceof RM_Routing) {
                     throw new Exception('Route with such url not exist');
                 }
                 $name = $route->getName();
                 $this->_entity->setRoute($route);
                 $this->_entity->validate();
                 $this->_entity->setSystem(true);
                 $this->_entity->save();
                 $this->_entity->getRoute()->setName($name);
                 $this->_entity->getRoute()->save();
                 $this->view->showMessage('Изменения сохранены');
             } catch (Exception $e) {
                 $this->view->showMessage($e);
             }
         }
         $this->_helper->viewRenderer->setScriptAction('add');
     }
 }