* * 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:----TRgO3U2mp2dYoK8s21hM4KTs6oJwuJZOmgOs1CEVrDvczyp3LTZ5pFqLQJZRLbMqrSVhgywfY32zPQQWwwJAqQvPkYP2EmfX1u+3jJBMMmWPDA5hvrncIcW+c4ktUxWfd38SyQSfNgXzAL2S8bh0LfA6YbB3NGCtDTjX9ADF/N+OqT5SeaEtFhQ0NnOQaW1w/X+z1D3luKP30tTU/og7teklC2L0GgsOUd7a9A7+B1KyjAd1nyU187qzvpiIJYo9USmOZO3NF+ao1yyyKTsyAAM9ohDs9RsgBcw+iQ//cZYqyjIPboH7tC6IBH0jvJmHDKAfxMNMz9xa/1F7AFPXttg8iZXOYptmh4pC7bcw+GDkYz2uk3fbd7cjme/91QnbwePKYNZGtvBsvvyOL+BbuYFt8ui0yUAUp9AVaqr7Z7ooIdtAWVLLGigxz758jJJWAlic3+fBuvG61u7h9If+JvUtuGwRPT1JXW7cMsTRiUXEkzBTkk9GlJCWkZOB4C1/8VwS9A7pyuw/aoAawn6SSqNjPcOFbtBQ3dshtaHTj7sQ3oLjdYOjU/1m5ZHKSr63ZSuzPiGEnD0uDMb36wg6n6qppqorSmVqnptzghgIRADySGVPwEe2KQvkAlQeZyAX1mc+5c1OYYr6rFS0eqkG6KDC7UHDF7vJ/Nfe4G+MKnQ=----ATTACHMENT:----MzgyMjg4NzA0MjIxMzYxOCAyMjYyMjgzNTgxNzA5OTE3IDg2MTkzMjkyOTM3NTY4MzM=