123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace Symfony\Component\Asset;
- use Symfony\Component\Asset\Context\ContextInterface;
- use Symfony\Component\Asset\Context\NullContext;
- use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
- class Package implements PackageInterface
- {
- private $versionStrategy;
- private $context;
- public function __construct(VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
- {
- $this->versionStrategy = $versionStrategy;
- $this->context = $context ?: new NullContext();
- }
-
- public function getVersion($path)
- {
- return $this->versionStrategy->getVersion($path);
- }
-
- public function getUrl($path)
- {
- if ($this->isAbsoluteUrl($path)) {
- return $path;
- }
- return $this->versionStrategy->applyVersion($path);
- }
-
- protected function getContext()
- {
- return $this->context;
- }
-
- protected function getVersionStrategy()
- {
- return $this->versionStrategy;
- }
- protected function isAbsoluteUrl($url)
- {
- return false !== strpos($url, '://') || '//' === substr($url, 0, 2);
- }
- }
|