コード例 #1
0
 public function load($file)
 {
     if (!is_file($file) || !is_readable($file)) {
         throw new Exception\ConfigLoaderException(sprintf('File "%s" is not readable or does not exist', $file));
     }
     return $this->container->getCache()->fetch('config', $file, function () use($file) {
         $info = pathinfo($file);
         $data = file_get_contents($file);
         switch (strtolower($info['extension'])) {
             case 'yml':
                 $data = Yaml::parse($data);
                 break;
             default:
                 throw new Exception\ConfigLoaderException(sprintf('File "%s" is not supported', $file));
         }
         return $data ? $data : array();
     }, filemtime($file));
 }
コード例 #2
0
 /**
  * @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;
     }
 }
コード例 #3
0
 protected function getCache()
 {
     return $this->container->getCache();
 }