示例#1
0
 /**
  * Looks up an error page using the CMS route "/error". If the route does not
  * exist, this function will use the error view found in the Cms module.
  * @return mixed Error page contents.
  */
 public function handleCustomError()
 {
     if (Config::get('app.debug', false)) {
         return null;
     }
     $theme = Theme::getActiveTheme();
     // Use the default view if no "/error" URL is found.
     $router = new Router($theme);
     if (!$router->findByUrl('/error')) {
         return View::make('cms::error');
     }
     // Route to the CMS error page.
     $controller = new Controller($theme);
     return $controller->run('/error');
 }
示例#2
0
 /**
  * Looks up an error page using the CMS route "/error". If the route does not
  * exist, this function will use the error view found in the Cms module.
  * @return mixed Error page contents.
  */
 public function handleCustomError()
 {
     if (Config::get('app.debug', false)) {
         return null;
     }
     $theme = Theme::getActiveTheme();
     // Use the default view if no "/error" URL is found.
     $router = new Router($theme);
     if (!$router->findByUrl('/error')) {
         return View::make('cms::error');
     }
     // Route to the CMS error page.
     $controller = new Controller($theme);
     $result = $controller->run('/error');
     // Extract content from response object
     if ($result instanceof \Symfony\Component\HttpFoundation\Response) {
         $result = $result->getContent();
     }
     return $result;
 }
示例#3
0
    public function testComponentWithOnRender()
    {
        $theme = Theme::load('test');
        $controller = new Controller($theme);
        $response = $controller->run('/component-custom-render')->getContent();
        $content = <<<ESC
Pass
Custom output: Would you look over Picasso's shoulder
Custom output: And tell him about his brush strokes?
ESC;
        $this->assertEquals($content, $response);
    }
示例#4
0
 public function testComponentAjax()
 {
     Request::swap($this->configAjaxRequestMock('testArchive::onTestAjax', 'ajax-result'));
     $theme = Theme::load('test');
     $controller = new Controller($theme);
     $response = $controller->run('/with-component');
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $content = $response->getOriginalContent();
     $this->assertInternalType('array', $content);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertCount(1, $content);
     $this->assertArrayHasKey('ajax-result', $content);
     $this->assertEquals('page', $content['ajax-result']);
 }