This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2014-12-28 18:57:17 +00:00
<?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\VersionStrategy;
/**
* Returns the same version for all assets.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class StaticVersionStrategy implements VersionStrategyInterface
{
private $version;
private $format;
2015-11-25 22:16:51 +00:00
/**
* @param string $version Version number
* @param string $format Url format
*/
2014-12-28 18:57:17 +00:00
public function __construct($version, $format = null)
{
$this->version = $version;
$this->format = $format ?: '%s?%s';
}
/**
* {@inheritdoc}
*/
public function getVersion($path)
{
return $this->version;
}
/**
* {@inheritdoc}
*/
public function applyVersion($path)
{
$versionized = sprintf($this->format, ltrim($path, '/'), $this->getVersion($path));
if ($path && '/' == $path[0]) {
return '/'.$versionized;
}
return $versionized;
}
}