您可以輕鬆更換EmptyVersionStrategy
,只是覆蓋服務,你可以看到如下:
應用程序/配置/ services.yml
services:
assets.empty_version_strategy:
class: FooBundle\Twig\Extension\AssetVersionStrategy
arguments: ["%kernel.root_dir%"]
的src/FooBundle \枝杈\ AssetVersionStrategy。 php
namespace FooBundle\Twig\Extension;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
/**
* AssetVersionStrategy (Twig)
*
* @author Your Name <[email protected]>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class AssetVersionStrategy implements VersionStrategyInterface
{
/**
* @var string
*/
private $root;
/**
* @param string $root
*/
public function __construct($root)
{
$this->root = $root;
}
/**
* Should return the version by the given path (starts from public root)
*
* @param string $path
* @return string
*/
public function getVersion($path)
{
return $path;
}
/**
* Determines how to apply version into the given path
*
* @param string $path
* @return string
*/
public function applyVersion($path)
{
return sprintf('%s?v=%s', $path, $this->getVersion($path));
}
}
來源
2016-05-23 14:23:29
Eru
我找到了[這個symfony ticket](https://github.com/symfony/sym fony/issues/15554),它基本上概述了同樣的問題,但目前還沒有提供解決方案。 – craigh