title: Symfony 2 EntityManager injection in service
body: <p>I've created my own service and I need to inject doctrine EntityManager, but I don't see that <code>__construct()</code> is called on my service, and injection doesn't work. </p>
  
  <p>Here is the code and configs:</p>
  
  <pre><code>&lt;?php
  
  namespace Test\CommonBundle\Services;
  use Doctrine\ORM\EntityManager;
  
  class UserService {
  
      /**
       *
       * @var EntityManager 
       */
      protected $em;
  
      public function __constructor(EntityManager $entityManager)
      {
          var_dump($entityManager);
          exit(); // I've never saw it happen, looks like constructor never called
          $this-&gt;em = $entityManager;
      }
  
      public function getUser($userId){
         var_dump($this-&gt;em ); // outputs null  
      }
  
  }
  </code></pre>
  
  <p>Here is <code>services.yml</code> in my bundle</p>
  
  <pre><code>services:
    test.common.userservice:
      class:  Test\CommonBundle\Services\UserService
      arguments: 
          entityManager: "@doctrine.orm.entity_manager"
  </code></pre>
  
  <p>I've imported that .yml in <code>config.yml</code> in my app like that</p>
  
  <pre><code>imports:
      # a few lines skipped, not relevant here, i think
      - { resource: "@TestCommonBundle/Resources/config/services.yml" }
  </code></pre>
  
  <p>And when I call service in controller</p>
  
  <pre><code>    $userservice = $this-&gt;get('test.common.userservice');
      $userservice-&gt;getUser(123);
  </code></pre>
  
  <p>I get an object (not null), but <code>$this-&gt;em</code> in UserService is null, and as I already mentioned, constructor on UserService has never been called</p>
  
  <p>One more thing, Controller and UserService are in different bundles (I really need that to keep project organized), but still: everyting else works fine, I can even call</p>
  
  <pre><code>$this-&gt;get('doctrine.orm.entity_manager')
  </code></pre>
  
  <p>in same controller that I use to get UserService and get valid (not null) EntityManager object.</p>
  
  <p>Look like that I'm missing piece of configuration or some link between UserService and Doctrine config.</p>