/** * validate a request object on basis of function-name(action) * * @param string $function * @param \Cms\Request\Abstract $actionRequest * @param boolean $setHttpErrorCode * @return true * @throws Exception */ public function validate($function, Request $actionRequest, $abortExceptions = true) { $methodName = 'validateMethod' . $function; if (method_exists($this, $methodName)) { try { $this->{$methodName}($actionRequest); } catch (PropertyAccessException $e) { $message = str_replace('%name%', $e->getName(), $this->_('error.validation.missing_parameter')); $this->addError(new Error($e->getName(), null, array($message))); } if (count($this->getErrors()) > 0) { foreach ($this->getErrors() as $error) { \Cms\ExceptionStack::addException($error); } if (count(\Cms\ExceptionStack::getExceptions()) > 0) { // soll nur der Status-Code veraendert werden (Bsp: Rueckgabe Images) if ($abortExceptions == true) { // bisherige Fehler loggen und reset foreach (\Cms\ExceptionStack::getExceptions() as $exception) { \Seitenbau\Registry::getLogger()->logException(__METHOD__, __LINE__, $exception, \Seitenbau\Log::NOTICE); } //\Cms\ExceptionStack::reset(); return false; } else { \Cms\ExceptionStack::throwErrors(); } } } return true; } else { $data = array('method' => $methodName); throw new \Cms\Exception(-12, __METHOD__, __LINE__, $data); } }
/** * Erstellt die komplette Ausgabe der Actions als JSON * Wirft evtl. aufgetretene Fehler */ public function postDispatch(\Zend_Controller_Request_Abstract $request) { // Exceptions ausgeben, wenn welche im Stack liegen $exceptions = \Cms\ExceptionStack::getExceptions(); if (count($exceptions) > 0) { \Cms\ExceptionStack::throwErrors(); } parent::postDispatch($request); }
/** * @test * @group library */ public function success() { $templateId = 'TPL-42b452d6-vi2d-4b56-b52c-aeaa49e541c9-TPL'; $websiteId = 'SITE-5sz2bve3-1cfg-4836-b847-1ab0571b1e6d-SITE'; $template = $this->templateBusiness->getById($templateId, $websiteId); $templateContent = \Zend_Json::decode($template->getContent()); \Cms\ExceptionStack::reset(); $pageContent = $this->reparseBusiness->generateNewPageContent($template); $this->assertEquals(0, count(\Cms\ExceptionStack::getExceptions()), 'Exception(s) occured'); $this->assertNotSame($templateContent, $pageContent); $this->checkGeneratedContent($templateContent, $pageContent); }
/** * @test * @group library */ public function reparseWebsiteSuccess() { $websiteId = 'SITE-5sz2bve3-1cfg-4836-b847-1ab0571b1e6d-SITE'; $pageService = $this->business->getService('Page'); $allPageIds = $pageService->getIdsByWebsiteId($websiteId); foreach ($allPageIds as $pageId) { $page = $pageService->getById($pageId, $websiteId); $pageContent[$page->getId()] = $page->getContent(); $templateContent[$page->getId()] = $page->getTemplatecontent(); } \Cms\ExceptionStack::reset(); $reparsedPageIds = $this->business->reparseWebsite($websiteId); $this->assertEquals(0, count(\Cms\ExceptionStack::getExceptions()), 'Exception(s) occured'); $this->assertSame(2, count($reparsedPageIds)); foreach ($allPageIds as $pageId) { $page = $pageService->getById($pageId, $websiteId); $this->assertContains($page->getId(), $reparsedPageIds); $this->assertNotSame($pageContent[$page->getId()], $page->getContent()); $this->assertNotSame($templateContent[$page->getId()], $page->getTemplatecontent()); } }
/** * Erstellt die komplette Ausgabe der Actions als JSON * Wirft evtl. aufgetretene Fehler */ public function postDispatch() { // Exceptions ausgeben, wenn welche im Stack liegen $exceptions = \Cms\ExceptionStack::getExceptions(); if (count($exceptions) > 0) { // response->data weitergeben? $data = $this->pushDataToErrorController === true ? $this->responseData->getData() : null; \Cms\ExceptionStack::throwErrors($data); } parent::postDispatch(); }