Thanks to visit codestin.com
Credit goes to github.com

Skip to content

inject asset packages in assets helper service #14419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader',
));
}

if ($container->hasDefinition('assets.packages')) {
$container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the helper service should be removed otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I didn't find circumstances where this ever will happen. If anyone can think of it, we could add a test covering it.

} else {
$container->removeDefinition('templating.helper.assets');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$container->loadFromExtension('framework', array(
'templating' => array(
'engines' => array('php', 'twig'),
),
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:templating>
<framework:engine>php</framework:engine>
<framework:engine>twig</framework:engine>
</framework:templating>
</framework:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
templating:
engines: [php, twig]
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,22 @@ public function testSerializerEnabled()
$this->assertTrue($container->has('serializer'));
}

public function testAssetHelperWhenAssetsAreEnabled()
{
$container = $this->createContainerFromFile('full');
$packages = $container->getDefinition('templating.helper.assets')->getArgument(0);

$this->assertSame('assets.packages', (string) $packages);
}

public function testAssetHelperWhenTemplatesAreEnabledAndAssetsAreDisabled()
{
$container = $this->createContainerFromFile('assets_disabled');
$packages = $container->getDefinition('templating.helper.assets')->getArgument(0);

$this->assertSame('assets.packages', (string) $packages);
}

protected function createContainer(array $data = array())
{
return new ContainerBuilder(new ParameterBag(array_merge(array(
Expand Down