1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?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\Templating\Asset;
- /**
- * An asset package.
- *
- * @author Kris Wallsmith <kris@symfony.com>
- */
- class AssetPackage implements AssetPackageInterface
- {
- private $baseUrls;
- private $version;
- /**
- * Constructor.
- *
- * @param array|string $baseUrls The domain URL or an array of domain URLs
- * @param string $version The version
- */
- public function __construct($baseUrls = array(), $version = null)
- {
- $this->baseUrls = array();
- $this->version = $version;
- foreach ((array) $baseUrls as $baseUrl) {
- $this->baseUrls[] = rtrim($baseUrl, '/');
- }
- }
- public function getVersion()
- {
- return $this->version;
- }
- public function getBaseUrl($path)
- {
- $count = count($this->baseUrls);
- if (0 === $count) {
- return '';
- }
- if (1 === $count) {
- return $this->baseUrls[0];
- }
- return $this->baseUrls[fmod(hexdec(substr(md5($path), 0, 10)), $count)];
- }
- }
|