vendor/symfony/asset/VersionStrategy/StaticVersionStrategy.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Asset\VersionStrategy;
  11. /**
  12.  * Returns the same version for all assets.
  13.  *
  14.  * @author Fabien Potencier <fabien@symfony.com>
  15.  */
  16. class StaticVersionStrategy implements VersionStrategyInterface
  17. {
  18.     private string $version;
  19.     private string $format;
  20.     /**
  21.      * @param string $version Version number
  22.      * @param string $format  Url format
  23.      */
  24.     public function __construct(string $versionstring $format null)
  25.     {
  26.         $this->version $version;
  27.         $this->format $format ?: '%s?%s';
  28.     }
  29.     /**
  30.      * {@inheritdoc}
  31.      */
  32.     public function getVersion(string $path): string
  33.     {
  34.         return $this->version;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public function applyVersion(string $path): string
  40.     {
  41.         $versionized sprintf($this->formatltrim($path'/'), $this->getVersion($path));
  42.         if ($path && '/' === $path[0]) {
  43.             return '/'.$versionized;
  44.         }
  45.         return $versionized;
  46.     }
  47. }