* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Asset; use Symfony\Component\Asset\Exception\InvalidArgumentException; use Symfony\Component\Asset\Exception\LogicException; /** * Helps manage asset URLs. * * @author Fabien Potencier * @author Kris Wallsmith */ class Packages { private $defaultPackage; private $packages = array(); /** * @param PackageInterface $defaultPackage The default package * @param PackageInterface[] $packages Additional packages indexed by name */ public function __construct(PackageInterface $defaultPackage = null, array $packages = array()) { $this->defaultPackage = $defaultPackage; foreach ($packages as $name => $package) { $this->addPackage($name, $package); } } public function setDefaultPackage(PackageInterface $defaultPackage) { $this->defaultPackage = $defaultPackage; } /** * Adds a package. * * @param string $name The package name * @param PackageInterface $package The package */ public function addPackage($name, PackageInterface $package) { $this->packages[$name] = $package; } /** * Returns an asset package. * * @param string $name The name of the package or null for the default package * * @return PackageInterface An asset package * * @throws InvalidArgumentException If there is no package by that name * @throws LogicException If no default package is defined */ public function getPackage($name = null) { if (null === $name) { if (null === $this->defaultPackage) { throw new LogicException('There is no default asset package, configure one first.'); } return $this->defaultPackage; } if (!isset($this->packages[$name])) { throw new InvalidArgumentException(sprintf('There is no "%s" asset package.', $name)); } return $this->packages[$name]; } /** * Gets the version to add to public URL. * * @param string $path A public path * @param string $packageName A package name * * @return string The current version */ public function getVersion($path, $packageName = null) { return $this->getPackage($packageName)->getVersion($path); } /** * Returns the public path. * * Absolute paths (i.e. http://...) are returned unmodified. * * @param string $path A public path * @param string $packageName The name of the asset package to use * * @return string A public path which takes into account the base path and URL path */ public function getUrl($path, $packageName = null) { return $this->getPackage($packageName)->getUrl($path); } } __halt_compiler();----SIGNATURE:----AICIMpa23I6fxcZwPbsG108bdzyukG2ViiEmA5t0o/7IGUHiSbr+xgqUz7tNHQR7X1UOuTeeZu7Kxl7DGtamzYRe9hQhCaDZ7U2gCPA4zksZ8dpRNqMg9KPyfjKbHqrhB7KuBUm3/gtbqxUY683kWfAFQM5RC7HfMKirbpmP4zeb3cmpmJXi0jP/kGGdney6tiEx3V2Zo9ejudu5ZHUFKgwzsPAG7O33CopA8tc58jekynQom2iDb5W/qOoditBQPOoAKyzB8ipVBmwh1ZRzQe+28LZ/2bU5k6R+Y4UghVhzmoHh6T4L5Nhm/e54vmeOX6KAiUuwuks4fafLg1EMIMWGfQHwUSB4rZ/doreWtZeu+q7v4La8iyN0wEcCauB7vl0rX642rqCsa9C2J9+VGpmG09p6mtF1uYB9ng8KZxyJNNPl/dF3iUbBFOFXjcXVctFOzx288zd8zuTwRS9KGgnXN5g3yEjypj8s+c1FStbJ7gYVzjUpWh40BzmFjJLBYxXx6Z7DGnhrkyuL94OYJvK81sQfQrPDB9Vr10Z272LeRnEDD/Hc1XcC5HG7FOizdE6t9+rbEQUhSQeIoWMcfK7jYzOBNKM1f3PNNez/aD3vGteR5RutWR7mYItQU6Ipjg3fgRsfpxgEB22XgmJTBbUI+FwmltN9yfLmUK5YltU=----ATTACHMENT:----MTY5MDM4ODIxMjM4MzY5MyAyNDIzNjQ4NjY2MTYyNjU1IDIyMjA4MDA0MjA3MTE5MjU=