Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function getFunctions()
 {
     return array_merge(parent::getFunctions(), [new Twig_SimpleFunction('cdn', function ($outputPath) {
         $basePath = rtrim($this->app['assets.output_path']);
         $assetPath = $basePath . '/' . $outputPath;
         $assetModified = file_exists($assetPath) ? filemtime($assetPath) : null;
         $cacheBuster = substr(sha1($assetModified), 0, 7);
         return rtrim($this->app['assets.output_uri'], '/') . '/' . $outputPath . '?' . $cacheBuster;
     })]);
 }