Exemple #1
0
 /**
  * renderNotFoundPage
  *
  * @param Site $site
  *
  * @return null|Page
  */
 public function renderNotFoundPage($site)
 {
     $page = $this->pageRepo->getPageByName($site, $site->getNotFoundPage(), 'n');
     if (empty($page)) {
         throw new PageNotFoundException('No default page defined for 404 not found error');
     }
     $response = $this->getResponse();
     $response->setStatusCode(410);
     return $page;
 }
Exemple #2
0
 /**
  * createTemplateFromPageAction
  *
  * @return Response|ViewModel
  * @throws \Rcm\Exception\PageNotFoundException
  */
 public function createTemplateFromPageAction()
 {
     if (!$this->rcmIsAllowed('sites.' . $this->currentSite->getSiteId() . '.pages', 'create')) {
         $response = new Response();
         $response->setStatusCode('401');
         return $response;
     }
     $sourcePage = $this->getEvent()->getRouteMatch()->getParam('rcmPageName', 'index');
     $sourcePageRevision = $this->getEvent()->getRouteMatch()->getParam('rcmPageRevision', null);
     $sourcePageType = $this->getEvent()->getRouteMatch()->getParam('rcmPageType', 'n');
     /** @var \RcmAdmin\Form\CreateTemplateFromPageForm $form */
     $form = $this->getServiceLocator()->get('FormElementManager')->get('RcmAdmin\\Form\\CreateTemplateFromPageForm');
     /** @var \Zend\Http\Request $request */
     $request = $this->request;
     $data = $request->getPost();
     $form->setValidationGroup('template-name');
     $form->setData($data);
     if ($request->isPost() && $form->isValid()) {
         $validatedData = $form->getData();
         $page = $this->pageRepo->getPageByName($this->currentSite, $sourcePage, $sourcePageType);
         if (empty($page)) {
             throw new PageNotFoundException('Unable to locate source page to copy');
         }
         $pageId = $page->getPageId();
         $pageData = ['author' => $this->rcmUserGetCurrentUser()->getName(), 'name' => $validatedData['template-name'], 'pageTitle' => null, 'pageType' => 't'];
         $this->pageRepo->copyPage($this->currentSite, $page, $pageData, $sourcePageRevision);
         $this->view->setVariable('newPageUrl', $this->urlToPage($validatedData['template-name'], 't'));
         $this->view->setTemplate('rcm-admin/page/success');
         return $this->view;
     }
     $this->view->setVariable('form', $form);
     $this->view->setVariable('rcmPageName', $sourcePage);
     $this->view->setVariable('rcmPageRevision', $sourcePageRevision);
     $this->view->setVariable('rcmPageType', $sourcePageType);
     return $this->view;
 }