public function handleRequest(HttpRequestA $oHttpRequest) { $oModel = new EmptyModel(); $oModel->setPageTitle('[ null ]'); $oModel->setPageContent('[ NULL ]'); return $oModel; }
/** * @covers \vsc\domain\models\EmptyModel::setPageContent */ public function testBasicSetPageContent() { $o = new EmptyModel(); $sContent = 'test content <p>some shit</p>'; $o->setPageContent($sContent); $this->assertEquals($sContent, $o->getPageContent()); }
/** * @covers \vsc\domain\models\EmptyModel::setPageTitle */ public function testBasicSetPageTitle() { $o = new EmptyModel(); $sTitle = 'test title'; $o->setPageTitle($sTitle); $this->assertEquals($sTitle, $o->getPageTitle()); }
/** * @param HttpRequestA $oRequest * @param ProcessorA $oProcessor * @throws ExceptionPath * @throws ExceptionResponse * @throws ExceptionView * @returns HttpResponseA */ public function getResponse(HttpRequestA $oRequest, $oProcessor = null) { $oResponse = vsc::getEnv()->getHttpResponse(); $oModel = null; /* @var ControllerMap $oMyMap */ $oMyMap = $this->getMap(); if (ProcessorA::isValid($oProcessor)) { try { $oProcessor->init(); $oModel = $oProcessor->handleRequest($oRequest); } catch (ExceptionResponseRedirect $e) { $oResponse->setStatus($e->getRedirectCode()); $oResponse->setLocation($e->getLocation()); return $oResponse; } catch (\Exception $e) { // we had error in the controller // @todo make more error processors return $this->getErrorResponse($e, $oRequest); } } if ($oResponse->getStatus() == 0) { $oResponse->setStatus(HttpResponseType::OK); } // we didn't set any special view // this means that the developer needs to provide his own views $oView = $this->getView(); $oMap = null; if (ProcessorA::isValid($oProcessor)) { /* @var ProcessorMap $oMap */ $oMap = $oProcessor->getMap(); if (MappingA::isValid($oMap)) { if (MappingA::isValid($oMyMap)) { $oMap->merge($oMyMap); } $oProcessorResponse = $oMap->getResponse(); if (HttpResponseA::isValid($oProcessorResponse)) { $oResponse = $oProcessorResponse; } } // setting the processor map $oView->setMap($oMap); } try { if ((ProcessorMap::isValid($oMap) || ClassMap::isValid($oMap)) && !$oMap->isStatic() && !$oMyMap->isStatic() && (ControllerMap::isValid($oMyMap) || ClassMap::isValid($oMyMap))) { $oView->setMainTemplate($oMyMap->getMainTemplatePath() . $oView->getViewFolder() . DIRECTORY_SEPARATOR . $oMyMap->getMainTemplate()); } } catch (ExceptionPath $e) { // fallback to html5 // @todo verify main template path and main template exist $oView->setMainTemplate($oMyMap->getMainTemplatePath() . DIRECTORY_SEPARATOR . 'html5' . DIRECTORY_SEPARATOR . $oMyMap->getMainTemplate()); } if (!ModelA::isValid($oModel)) { $oModel = new EmptyModel(); if (!ProcessorMap::isValid($oMap) || $oMap->getTitle() == '') { $oModel->setPageTitle('Warning'); } $oModel->setPageContent('Warning: the processor didn\'t return a valid model. This is probably an error'); } $oView->setModel($oModel); $oResponse->setView($oView); if (MappingA::isValid($oMap)) { $aHeaders = $oMap->getHeaders(); if (count($aHeaders) > 0) { foreach ($aHeaders as $sName => $sHeader) { $oResponse->addHeader($sName, $sHeader); } } $iProcessorSetStatus = $oMap->getResponseStatus(); if (HttpResponseType::isValidStatus($iProcessorSetStatus)) { $oResponse->setStatus($iProcessorSetStatus); } } return $oResponse; }