title: Symfony 4 access parameters inside of repository
body: <p>I have a repository class called EmailRepository</p>
  
  <pre><code>class EmailRepository extends EntityRepository implements ContainerAwareInterface { ... }
  </code></pre>
  
  <p>I need to get a parameter injected into this repository class but I dont know how... </p>
  
  <p>This is what I currently have inside of the repository, which is being called from my controller:</p>
  
  <p><strong>Controller:</strong> </p>
  
  <pre><code>$em-&gt;getRepository(Email::class)-&gt;getEmailApi();
  </code></pre>
  
  <p><strong>Repository</strong>     </p>
  
  <pre><code>class EmailRepository extends EntityRepository implements ContainerAwareInterface {    
  
       protected $container;
       public function setContainer(ContainerInterface $container = null) {
           $this-&gt;container = $container;
       }
  
       /**
        * @param $array
        */
       public function getEmailApi($array)
       {
  
           echo $this-&gt;container-&gt;getParameter('email_api');
       }
  }
  </code></pre>
  
  <p>I always get this error: </p>
  
  <pre><code> Call to a member function getParameter() on null
  </code></pre>
  
  <p><strong>The parameter is not null, it does have a value.</strong> I know it's telling me that $this->container is null. How do I fix this? </p>
  
  <p>If I run this inside of my controller, it works fine and returns <strong>Google</strong></p>
  
  <pre><code> echo $this-&gt;getParameter('email_api');
  </code></pre>