Changed service_container to router in UserDataSpan Twig extension

Actually, only router was used by retrieving it from the container. Now
injecting only what is necessary.

Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-08-01 08:48:16 +02:00
parent cc7ce78787
commit 7f83e2f9c4
2 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@
<tag name="kernel.event_listener" event="security.authentication.success" />
</service>
<service id="kek_rozsak_security.twig_extension.userdataspan" class="KekRozsak\SecurityBundle\Twig\UserDataSpanExtension">
<argument type="service" id="service_container" />
<argument type="service" id="router" />
<argument type="service" id="security.context" />
<tag name="twig.extension" />
</service>

View File

@ -3,18 +3,18 @@
namespace KekRozsak\SecurityBundle\Twig;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use KekRozsak\SecurityBundle\Entity\User;
class UserDataSpanExtension extends \Twig_Extension
{
protected $_securityContext;
protected $_serviceContainer;
protected $_router;
public function __construct(ContainerInterface $container, SecurityContextInterface $security)
public function __construct(Router $router, SecurityContextInterface $security)
{
$this->_serviceContainer = $container;
$this->_router = $router;
$this->_securityContext = $security;
}
@ -30,7 +30,7 @@ class UserDataSpanExtension extends \Twig_Extension
if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser()))
return '<span class="userdata-secret" title="|Felhasználó|A felhasználóink kiléte szigorúan bizalmas, csak a tagok számára elérhető.">[nem jelenhet meg]</span>';
return '<span class="userdata" rel="' . $this->_serviceContainer->get('router')->generate('KekRozsakSecurityBundle_ajaxUserdata', array('id' => $user->getId(), '_format' => 'html')) . '">' . $user->getDisplayName() . '</span>';
return '<span class="userdata" rel="' . $this->_router->generate('KekRozsakSecurityBundle_ajaxUserdata', array('id' => $user->getId(), '_format' => 'html')) . '"><a href="">' . $user->getDisplayName() . '</a></span>';
}
public function getName()