Ejemplo n.º 1
0
 public function deleteAction($id)
 {
     $model = Page::findFirst($id);
     if ($this->request->isPost()) {
         $model->delete();
         $this->redirect('/page/admin');
     }
     $this->view->model = $model;
     $this->view->title = 'Удаление страницы';
     $this->helper->title('Удаление страницы');
 }
Ejemplo n.º 2
0
 /**
  * Action responsible to display info about single page entity.
  *
  * @return \Phalcon\Http\ResponseInterface
  * @throws \Api\Exception\NotImplementedException
  */
 public function getAction()
 {
     //get entity from storage
     $pageId = (int) $this->request->getQuery('pageId');
     $page = \Page\Model\Page::findFirst($pageId);
     if (!$pageId || !$page) {
         return $this->render(new \Api\Model\Payload(null, sprintf('Page with id: %s was not found.', $pageId)));
     }
     //filter required data for display
     $filter = new \Api\Filter\Page();
     $payload = new \Api\Model\Payload($filter->filter($page));
     return $this->render($payload);
 }
Ejemplo n.º 3
0
 public function deleteAction($id)
 {
     $model = Page::findFirst($id);
     if ($model->getSlug() == 'index') {
         $this->flash->error($this->helper->at('Index page can not be removed'));
         return $this->redirect($this->url->get() . 'page/admin');
     }
     if ($this->request->isPost()) {
         $model->delete();
         $this->redirect($this->url->get() . 'page/admin');
     }
     $this->view->model = $model;
     $this->helper->title($this->helper->at('Delete Page'), true);
 }