3 namespace Rapsys\PackBundle\Asset
; 
   5 use Symfony\Component\Asset\Context\ContextInterface
; 
   6 use Symfony\Component\Asset\PathPackage 
as BasePackage
; 
   7 use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface
; 
  12 class PathPackage 
extends BasePackage 
{ 
  19         public function __construct(string $basePath, VersionStrategyInterface 
$versionStrategy, ContextInterface 
$context = null) { 
  20                 parent
::__construct($basePath, $versionStrategy, $context); 
  23                         $this->basePath 
= '/'; 
  25                         if ('/' != $basePath[0]) { 
  26                                 $basePath = '/'.$basePath; 
  29                         $this->basePath 
= rtrim($basePath, '/').'/'; 
  36         public function getUrl($path) { 
  37                 //Match url starting with a bundle name 
  38                 if (preg_match('%^@([A-Z][a-zA-Z]*)Bundle/Resources/public(/.*)$%', $path, $matches)) { 
  39                         //Handle empty or without replacement pattern basePath 
  40                         if (empty($this->basePath
) || strpos($this->basePath
, '%s') === false) { 
  41                                 //Set path from hardcoded format 
  42                                 $path = '/bundles/'.strtolower($matches[1]).$matches[2]; 
  43                         //Proceed with basePath pattern replacement 
  45                                 //Set path from basePath pattern 
  46                                 $path = sprintf($this->basePath
, strtolower($matches[1])).$matches[2]; 
  50                 //Return parent getUrl result 
  51                 return parent
::getUrl($path);