<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * 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\Context\ContextInterface; use Symfony\Component\Asset\Context\NullContext; use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface; /** * Basic package that adds a version to asset URLs. * * @author Kris Wallsmith <kris@symfony.com> * @author Fabien Potencier <fabien@symfony.com> */ class Package implements PackageInterface { private $versionStrategy; private $context; public function __construct(VersionStrategyInterface $versionStrategy, ContextInterface $context = null) { $this->versionStrategy = $versionStrategy; $this->context = $context ?: new NullContext(); } /** * {@inheritdoc} */ public function getVersion($path) { return $this->versionStrategy->getVersion($path); } /** * {@inheritdoc} */ public function getUrl($path) { if ($this->isAbsoluteUrl($path)) { return $path; } return $this->versionStrategy->applyVersion($path); } /** * @return ContextInterface */ protected function getContext() { return $this->context; } /** * @return VersionStrategyInterface */ protected function getVersionStrategy() { return $this->versionStrategy; } protected function isAbsoluteUrl($url) { return false !== strpos($url, '://') || '//' === substr($url, 0, 2); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Context | Folder | 0755 |
|
|
Exception | Folder | 0755 |
|
|
Tests | Folder | 0755 |
|
|
VersionStrategy | Folder | 0755 |
|
|
.gitignore | File | 34 B | 0644 |
|
CHANGELOG.md | File | 354 B | 0644 |
|
LICENSE | File | 1.04 KB | 0644 |
|
Package.php | File | 1.67 KB | 0644 |
|
PackageInterface.php | File | 775 B | 0644 |
|
Packages.php | File | 3.06 KB | 0644 |
|
PathPackage.php | File | 2.19 KB | 0644 |
|
README.md | File | 557 B | 0644 |
|
UrlPackage.php | File | 3.98 KB | 0644 |
|
composer.json | File | 856 B | 0644 |
|
phpunit.xml.dist | File | 832 B | 0644 |
|