protected function generateResponseForRequest($request = false) { if ($this->staticFile !== false) { $response = new Response(); LayoutModule::disableLayout(); if (substr($this->staticFile, -4) == ".css") { $mime = "text/css"; } else { $info = new \finfo(FILEINFO_MIME); $mime = $info->file($this->staticFile); } if ($mime !== false) { if (substr($this->staticFile, -3) == ".js") { $mime = str_replace("text/plain", "application/javascript", $mime); } HttpHeaders::setHeader("Content-type", $mime); $response->setHeader('Content-Type', $mime); } ob_start(); readfile($this->staticFile); $response->setContent(ob_get_clean()); return $response; } return false; }
protected function printLayout($content) { ?> <html> <head> <title><?php echo $this->getTitle(); ?> </title> <?php echo LayoutModule::getHeadItemsAsHtml(); ?> <?php echo ResourceLoader::getResourceInjectionHtml(); ?> <?php $this->printHead(); ?> </head> <body> <?php $this->printTop(); echo LayoutModule::getBodyItemsAsHtml(); $this->printPageHeading(); $this->printContent($content); $this->printTail(); ?> </body> </html> <?php }
protected function setUp() { parent::setUp(); $this->application->context()->simulateNonCli = true; $this->request = $this->application->request(); $this->request->IsWebRequest = true; LayoutModule::disableLayout(); }
protected function createView() { if (!CustomLoginProvider::isAdmin()) { throw new ForceResponseException(new RedirectResponse('../')); } LayoutModule::setLayoutClassName(PortalLayout::class); return new GalleryChangeView(); }
public function testUrlExtractedFromHandler() { LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/computed-url/test/"; $response = $this->application->generateResponseForRequest($request); $this->assertEquals("TopComputed URL ResponseTail", $response->getContent()); }
public function testStaticFileDisablesLayout() { LayoutModule::enableLayout(); $handler = new StaticResourceUrlHandler(__DIR__ . "/../../Fixtures/UrlHandlers/test.txt"); $handler->setUrl("/test.txt"); $this->request->urlPath = "/test.txt"; $handler->generateResponse($this->request); $this->assertTrue(LayoutModule::isDisabled()); }
public function generateResponse($request = null) { if (class_exists("Rhubarb\\Crown\\Layout\\LayoutModule")) { LayoutModule::disableLayout(); } $schemas = SolutionSchema::getAllSchemas(); foreach ($schemas as $schema) { $schema->checkModelSchemas(); } $response = new HtmlResponse(); $response->setContent("Done"); return $response; }
public function processResponse($response) { if (LayoutModule::isDisabled()) { return $response; } if (!$response instanceof HtmlResponse) { return $response; } $className = LayoutModule::getLayoutClassName(); if (!class_exists($className)) { throw new LayoutNotFoundException($className); } $layout = new $className(); $layout->processResponse($response); return $response; }
protected function createView() { LayoutModule::disableLayout(); return new ImgView(); }
protected function setUp() { $this->request = Context::CurrentRequest(); $this->request->IsWebRequest = true; LayoutModule::disableLayout(); }
protected function createView() { LayoutModule::setLayoutClassName(PortalLayout::class); return new GalleryCollectionView(); }
public function testDisablingTrapping() { ExceptionHandler::disableExceptionTrapping(); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->UrlPath = "/test-exception/"; $response = Module::generateResponseForRequest($request); $this->fail("Without exception trapping this line should not be reached."); } catch (RhubarbException $er) { } ExceptionHandler::setExceptionHandlerClassName('\\Rhubarb\\Crown\\Tests\\Exceptions\\Handlers\\UnitTestDisobedientExceptionHandler'); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->UrlPath = "/test-exception/"; $response = Module::generateResponseForRequest($request); } catch (RhubarbException $er) { $this->fail("The extended exception handler should force handling of exceptions even if trapping is disabled."); } ExceptionHandler::enableExceptionTrapping(); LayoutModule::disableLayout(); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); LayoutModule::setLayoutClassName("Rhubarb\\Crown\\Tests\\Layout\\TestLayout"); LayoutModule::disableLayout(); }
protected function createView() { LayoutModule::setLayoutClassName(PortalLayout::class); return new UsersView(); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); LayoutModule::setLayoutClassName(TestLayout::class); LayoutModule::disableLayout(); }
protected function createView() { LayoutModule::setLayoutClassName(BottomPageLayout::class); return new ThanksView(); }
public function __construct($name = "") { LayoutModule::setLayoutClassName(PortalLayout::class); parent::__construct($name); }
public function testDisablingTrapping() { ExceptionHandler::disableExceptionTrapping(); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/test-exception/"; $response = $this->application->generateResponseForRequest($request); $this->fail("Without exception trapping this line should not be reached."); } catch (RhubarbException $er) { } $this->application->container()->registerClass(ExceptionHandler::class, UnitTestDisobedientExceptionHandler::class); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/test-exception/"; $response = $this->application->generateResponseForRequest($request); } catch (RhubarbException $er) { $this->fail("The extended exception handler should force handling of exceptions even if trapping is disabled."); } ExceptionHandler::enableExceptionTrapping(); LayoutModule::disableLayout(); }