/**
  * @param RequestResponseEvent $event
  */
 public function listen(RequestResponseEvent $event)
 {
     $path = $event->getRequest()->getPathInfo();
     $parts = pathinfo($path);
     $parts = array_merge(array('dirname' => '', 'basename' => '', 'extension' => '', 'filename'), $parts);
     switch (strtolower($parts['extension'])) {
         case 'css':
             //possible it's not yet compiled less file?
             $lessFile = $this->container->getApplication()->getWebRoot() . $path . '.less';
             if (is_file($lessFile)) {
                 $asset = new FileAsset($lessFile);
                 $asset->ensureFilter(new LessphpFilter());
                 $content = $this->container->getCache()->fetch('assets_404', $path, function () use($asset) {
                     return $asset->dump();
                 }, $asset->getLastModified(), 0, true);
                 $event->setResponse(new Response($content, 200, array('Content-Type' => 'text/css')));
                 $event->stopPropagation();
                 return;
             }
             break;
     }
 }
Beispiel #2
0
 public function testGetLastModifiedValue()
 {
     $asset = new FileAsset(__FILE__);
     $this->assertLessThan(time(), $asset->getLastModified(), '->getLastModified() returns the mtime');
 }