title: Symfony2: Inject current user in Service
body: <p>I am trying to inject the currently logged in user into a service. My goal is to extend some twig functionality to output it based on user preferences. In this example I want to output any date function using the user specific Timezone.</p>
  
  <p>There doesn't seem to be any way to inject the current user into a service, which seems really odd to me. When injecting the security context, it doesn't have a token even if the user is logged in</p>
  
  <p>I am using FOS user bundle.</p>
  
  <pre><code>services:
      ...
      twigdate.listener.request:
          class: App\AppBundle\Services\TwigDateRequestListener
          arguments: [@twig, @security.context]
          tags:
              - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
  
  
  &lt;?php
  
  namespace App\AppBundle\Services;
  
  use Symfony\Component\HttpKernel\HttpKernelInterface;
  use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  
  class TwigDateRequestListener
  {
      protected $twig;
  
      function __construct(\Twig_Environment $twig, SecurityContext $context) {
  
          $this-&gt;twig = $twig;
          //$this-&gt;user = $context-&gt;get...;
  
          var_dump($context); die;
      }
  
      public function onKernelRequest(GetResponseEvent $event) {
         // $this-&gt;twig-&gt;getExtension('core')-&gt;setDateFormat($user-&gt;getProfile()-&gt;getFormat());
         // $this-&gt;twig-&gt;getExtension('core')-&gt;setTimeZone($user-&gt;getProfile()-&gt;getTimezone());
      }
  }
  
  output:
  
  object(Symfony\Component\Security\Core\SecurityContext)[325]
    private 'token' =&gt; null
    private 'accessDecisionManager' =&gt; 
      object(Symfony\Component\Security\Core\Authorization\AccessDecisionManager)[150]
        private 'voters' =&gt; 
          array
            0 =&gt; 
              object(Symfony\Component\Security\Core\Authorization\Voter\RoleHierarchyVoter)[151]
                ...
            1 =&gt; 
              object(Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter)[153]
                ...
            2 =&gt; 
              object(Symfony\Component\Security\Acl\Voter\AclVoter)[155]
                ...
        private 'strategy' =&gt; string 'decideAffirmative' (length=17)
        private 'allowIfAllAbstainDecisions' =&gt; boolean false
        private 'allowIfEqualGrantedDeniedDecisions' =&gt; boolean true
    private 'authenticationManager' =&gt; 
      object(Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager)[324]
        private 'providers' =&gt; 
          array
            0 =&gt; 
              object(Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider)[323]
                ...
            1 =&gt; 
              object(Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider)[149]
                ...
        private 'eraseCredentials' =&gt; boolean true
    private 'alwaysAuthenticate' =&gt; boolean false
  </code></pre>
  
  <p>Am I missing something?</p>