Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getUrl($path)
 {
     if ($this->isAbsoluteUrl($path)) {
         return $path;
     }
     $theme = $this->themeContext->getTheme();
     if (null !== $theme) {
         $path = $this->pathResolver->resolve($path, $theme);
     }
     return $this->getBasePath() . ltrim($this->getVersionStrategy()->applyVersion($path), '/');
 }
Exemplo n.º 2
0
 function it_returns_modified_url_if_there_is_active_theme(ThemeContextInterface $themeContext, VersionStrategyInterface $versionStrategy, PathResolverInterface $pathResolver, ThemeInterface $theme)
 {
     $path = 'bundles/sample/asset.js';
     $themeAssetPath = 'bundles/theme/foo/bar/sample/asset.js';
     $themeContext->getTheme()->shouldBeCalled()->willReturn($theme);
     $pathResolver->resolve($path, $theme)->shouldBeCalled()->willReturn($themeAssetPath);
     $versionStrategy->applyVersion($themeAssetPath)->shouldBeCalled()->willReturn($themeAssetPath);
     $this->getUrl($path)->shouldReturn('/' . $themeAssetPath);
 }
 /**
  * @param ThemeInterface $theme
  * @param string $originDir
  * @param string $targetDir
  * @param integer $symlinkMask
  *
  * @return integer
  */
 protected function installThemedBundleAssets(ThemeInterface $theme, $originDir, $targetDir, $symlinkMask)
 {
     $effectiveSymlinkMask = $symlinkMask;
     $finder = new Finder();
     $finder->sortByName()->ignoreDotFiles(false)->in($originDir);
     /** @var SplFileInfo[] $finder */
     foreach ($finder as $originFile) {
         $targetFile = $targetDir . '/' . $originFile->getRelativePathname();
         $targetFile = $this->pathResolver->resolve($targetFile, $theme);
         if (file_exists($targetFile)) {
             continue;
         }
         $this->filesystem->mkdir(dirname($targetFile));
         $effectiveSymlinkMask = min($effectiveSymlinkMask, $this->installAsset($originFile->getPathname(), $targetFile, $symlinkMask));
     }
     return $effectiveSymlinkMask;
 }