fix for legacy asset() with EmptyVersionStrategy
This commit is contained in:
parent
2217c1faec
commit
cf86a03b98
@ -108,11 +108,15 @@ class AssetExtension extends \Twig_Extension
|
|||||||
$v->setAccessible(true);
|
$v->setAccessible(true);
|
||||||
$currentVersionStrategy = $v->getValue($package);
|
$currentVersionStrategy = $v->getValue($package);
|
||||||
|
|
||||||
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
if (property_exists($currentVersionStrategy, 'format')) {
|
||||||
$f->setAccessible(true);
|
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
||||||
$format = $f->getValue($currentVersionStrategy);
|
$f->setAccessible(true);
|
||||||
|
$format = $f->getValue($currentVersionStrategy);
|
||||||
|
|
||||||
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
||||||
|
} else {
|
||||||
|
$v->setValue($package, new StaticVersionStrategy($version));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bridge\Twig\Extension\AssetExtension;
|
|||||||
use Symfony\Component\Asset\Package;
|
use Symfony\Component\Asset\Package;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\Asset\PathPackage;
|
use Symfony\Component\Asset\PathPackage;
|
||||||
|
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
|
||||||
class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -41,6 +42,16 @@ class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('/foo/me.png?version=42', $extension->getAssetUrl('me.png', null, false, 42));
|
$this->assertEquals('/foo/me.png?version=42', $extension->getAssetUrl('me.png', null, false, 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
|
public function testGetAssetUrlWithEmptyVersionStrategy()
|
||||||
|
{
|
||||||
|
$extension = $this->createExtension(new PathPackage('foo', new EmptyVersionStrategy()));
|
||||||
|
|
||||||
|
$this->assertEquals('/foo/me.png?42', $extension->getAssetUrl('me.png', null, false, 42));
|
||||||
|
}
|
||||||
|
|
||||||
private function createExtension(Package $package)
|
private function createExtension(Package $package)
|
||||||
{
|
{
|
||||||
$foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();
|
$foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();
|
||||||
|
Reference in New Issue
Block a user