title: how to use class controller functions in command class of symfony 2?
body: <p>I am building a batch file using symfony 2 command class. I have a function which deals with DB from a controller inside a bundle </p>
  
  <p><code>class SubmitDisclosureController extends FOSRestController  implements MEAuthController
  {
  ...
      public function discDetails($discId) {<br>
          $emr = $this-&gt;getDoctrine()-&gt;getEntityManager();</code></p>
  
  <p>I am calling this from a command <code>src/AppBundle/Command/BatchJobCommand.php
  </code> which is as below </p>
  
  <pre><code>class BatchJobCommand extends Command
  {
  protected function execute(InputInterface $input, OutputInterface $output)
  {
      $output-&gt;writeln([
              'User Creator',
              '============',
              '',
          ]);
  
      // retrieve the argument value using getArgument()
      $output-&gt;writeln('First batch job')
  
      $disc = new SubmitDisclosureController();
      $disc-&gt;discDetails('42094');
  `
  </code></pre>
  
  <p>If I try to execute it, it gives <code>PHP Fatal error:  Call to a member function has() on null in C:\xampp\htdocs\GR\
  vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.
  php on line 288</code></p>
  
  <p>is it not possible to re-use the code by calling the functions of a controller from a command class? </p>