From d3691f2633844491e050af1dce87150532d7420a Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Sat, 27 Jan 2018 19:10:21 +0100 Subject: [PATCH] inject router instead of whole container --- Resources/config/config.xml | 2 +- Templating/Helper/GravatarHelper.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Resources/config/config.xml b/Resources/config/config.xml index b7ad5b1..6e25582 100644 --- a/Resources/config/config.xml +++ b/Resources/config/config.xml @@ -16,7 +16,7 @@ - + diff --git a/Templating/Helper/GravatarHelper.php b/Templating/Helper/GravatarHelper.php index 5b58987..7b52aab 100644 --- a/Templating/Helper/GravatarHelper.php +++ b/Templating/Helper/GravatarHelper.php @@ -3,7 +3,7 @@ namespace Ornicar\GravatarBundle\Templating\Helper; use Ornicar\GravatarBundle\GravatarApi; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Templating\Helper\Helper; /** @@ -20,19 +20,20 @@ class GravatarHelper extends Helper implements GravatarHelperInterface protected $api; /** - * @var ContainerInterface + * @var RouterInterface */ - protected $container; + protected $router; /** * Constructor. * - * @param Ornicar\GravatarBundle\GravatarApi $api + * @param GravatarApi $api + * @param RouterInterface|null $router */ - public function __construct(GravatarApi $api, ContainerInterface $container = null) + public function __construct(GravatarApi $api, RouterInterface $router = null) { $this->api = $api; - $this->container = $container; + $this->router = $router; } /** @@ -98,11 +99,11 @@ protected function isSecure($preset = true) return !!$preset; } - if (!$this->container || !$this->container->has('router')) { + if (null === $this->router) { return false; } - return 'https' == strtolower($this->container->get('router')->getContext()->getScheme()); + return 'https' == strtolower($this->router->getContext()->getScheme()); } /**