Beispiel #1
0
 /**
  * @global type $container
  * @param type $path
  * @param type $filename
  * @return BinaryFileResponse
  */
 protected function downloadFile($path, $filename)
 {
     global $container;
     $session = $container->get('session');
     $session->save();
     $filenameFallback = str_replace('%', '_', $filename);
     $filenameFallback = str_replace('/', '_', $filenameFallback);
     $filenameFallback = str_replace('\\', '_', $filenameFallback);
     $response = new BinaryFileResponse($path);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename, $filenameFallback);
     if (pathinfo($filename, PATHINFO_EXTENSION) == 'docx') {
         $response->headers->set('Content-Type', '');
         // otherwise mineType would be zip
     }
     $logger = $container->get("logger");
     $logger->pushHandler(new NullHandler(Logger::DEBUG));
     BrowserConsoleHandler::reset();
     return $response;
 }
 protected function setUp()
 {
     BrowserConsoleHandler::reset();
 }
    public function testConcurrentHandlers()
    {
        $handler1 = new BrowserConsoleHandler();
        $handler1->setFormatter($this->getIdentityFormatter());
        $handler2 = new BrowserConsoleHandler();
        $handler2->setFormatter($this->getIdentityFormatter());
        $handler1->handle($this->getRecord(Logger::DEBUG, 'test1'));
        $handler2->handle($this->getRecord(Logger::DEBUG, 'test2'));
        $handler1->handle($this->getRecord(Logger::DEBUG, 'test3'));
        $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
        $expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
c.log("%ctest1", "font-weight: normal");
c.log("%ctest2", "font-weight: normal");
c.log("%ctest3", "font-weight: normal");
c.log("%ctest4", "font-weight: normal");
}})(console);
EOF;
        $this->assertEquals($expected, $this->generateScript());
    }