title: Doctrine \ ORM \ EntityManager, unspecified in class MessageComponentInterface
body: <p>i'm using Ratchet websocket library in my project on symfony 2.8.
  my problem is how to define the entity manager that exist in another controller's methode.</p>
  <pre><code>class WesocketController implements MessageComponentInterface
  {
      protected $clients;
  
      public function __construct()
      {
          $this-&gt;clients = new \SplObjectStorage;
      }
  
      public function onMessage(ConnectionInterface $from, $msg)
      {
          echo $msg;
          $numRecv = count($this-&gt;clients) - 1;
          echo sprintf('Connection %d sending message &quot;%s&quot; to %d other connection%s' . &quot;\n&quot;
              , $from-&gt;resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');
  
          $myController = new OtherController();
          $myController-&gt;test();
  
          foreach ($this-&gt;clients as $client) {
              if ($from !== $client) {
                  // The sender is not the receiver, send to each client connected
                  $client-&gt;send($msg);
              }
          }
      }
  }
  </code></pre>
  <p>My function in the othe controller:</p>
  <pre><code>public function test()
  {
      // echo('yassine');
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      $newTest = new VisitsTest();
      $newVisitsTest
          -&gt;setTestDate(new \DateTime())
          -&gt;setClient(null);
      $em-&gt;persist($newTest);
      $em-&gt;flush();
  }
  </code></pre>
  <p>ERROR:</p>
  <pre><code>PHP Fatal error:  Uncaught Error: Call to a member function has() on null in MyApp/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
  </code></pre>
  <p>The error is on this line in the other controller</p>
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
  </code></pre>
  <p>PLease help how to resolve this problem</p>
  <p>Thanks</p>