Now injecting services with JMSDiExtraBundle

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI
2012-08-16 19:06:00 +02:00
parent cd361a8ca9
commit 1d0a513ea2
9 changed files with 123 additions and 84 deletions

View File

@@ -2,15 +2,26 @@
namespace KekRozsak\FrontBundle\Twig;
use Symfony\Component\DependencyInjection\ContainerInterface;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service
* @DI\Tag("twig.extension")
*
*/
class TwigBBExtension extends \Twig_Extension
{
private $container;
private $assets;
/**
* @DI\InjectParams({
* "container" = @DI\Inject("service_container")
* })
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->assets = $container->get('templating.helper.assets');
}
public function getFilters()
@@ -67,8 +78,7 @@ class TwigBBExtension extends \Twig_Extension
$sentence,
'<img src="'
. $this
->container
->get('templating.helper.assets')
->assets
->getUrl(
'upload/images/'
. (($ns == '') ? '' : $ns . '/')