Пример #1
0
 public function execute()
 {
     try {
         $req = $this->request();
         $id = $req->get('id');
         if ($id === null || ($this->_item = $this->em()->find($this->_entityCls, $id)) == null) {
             $this->error($this->_invalidIdMsg);
             return;
         }
         if ($req->get('submit') !== null) {
             $this->_form = $form = $this->prepareForm(new $this->_formCls($this->_formId, $this->_formName, $this->_formAct . "&id=" . $this->_item->getId(), $this->_formMethod, $this->_formEnctype, 'save'));
             if ($this->_form->validate()) {
                 $em = $this->em();
                 $this->_item = $em->find($this->_entityCls, $id);
                 $this->setItemFields();
                 $em->flush();
                 Application::instance()->redirect($this->_redirectUrl);
                 return;
             }
         }
         parent::execute();
     } catch (\ru\nazarov\crm\exceptions\ErrorException $e) {
         $this->error($e->mes, $e->back);
     }
 }
Пример #2
0
 public function execute()
 {
     try {
         $this->checkRemovePossibility();
         $em = $this->em();
         $this->customActions();
         $em->remove($this->_item);
         $em->flush();
         Application::instance()->redirect($this->_redirectUrl);
     } catch (\ru\nazarov\crm\exceptions\ErrorException $e) {
         $this->error($e->mes, $e->back);
     }
 }
Пример #3
0
 protected function error($mes, $back = null)
 {
     $this->request()->set('mes', $mes)->set('action', 'error')->set('back', isset($back) ? $back : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null));
     Application::instance()->run($this->request());
 }