Beispiel #1
0
 /**
  * @covers \Bolt\Controller\Zone::get
  * @covers \Bolt\Controller\Zone::isAsync
  */
 public function testControllerZone()
 {
     $app = $this->getApp();
     $this->allowLogin($app);
     $this->setRequest(Request::create('/async'));
     $request = $this->getRequest();
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $app['dispatcher']->dispatch(KernelEvents::REQUEST, new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
     $this->assertEquals('async', Zone::get($request));
     $this->assertTrue(Zone::isAsync($request));
 }
Beispiel #2
0
 /**
  * Callback for reponse event.
  *
  * @param FilterResponseEvent $event
  */
 public function onResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $response = $event->getResponse();
     if (strpos($response->headers->get('Content-Type'), 'text/html') === false) {
         return;
     }
     if (!Zone::isAsync($event->getRequest())) {
         $this->addSnippets();
     }
     $response->setContent($this->render->postProcess($response));
 }