title: How to extend EntityRepository in Symfony2?
body: <p>I got this problem I have a method that is repetitive in all the Repositories,  for example this method.</p>
  
  <pre><code>function getAllOrderedBy($column) {
  
      $qb = $this-&gt;createQueryBuilder('ac')
              -&gt;select('ac')
              -&gt;orderBy('ac.' . $column);
  
      return $qb-&gt;getQuery()-&gt;getResult();
  }
  </code></pre>
  
  <p>I want to extract it in another superclass, OrderedRepository for example and use it as the base class for all the other repositories.</p>
  
  <p>Now the problem is how to do that ?</p>
  
  <p>I tried to instantiate EntityRepository in the constructor of the OrderedRepository,
  something like this, but also instantiating there all the internal objects, needed for other stuff, but it didn't really worked, and I felt it is the wrong path to follow.</p>
  
  <pre><code>function __construct() {
  
    parent::__construct();
    $this-&gt;blabla_option = "instantiated";
  }
  </code></pre>
  
  <p>Could you please give an example of correct extending of EntityRepository so than this extended class could serve as a base class for other repositories ?</p>
  
  <p>P.S. I'm a begginer in PHP so please excuse me if I hurt your feelings with my unawareness.</p>