Choose between two queryBuilders in a method
<p>I have an awkward situation with a method that is used on two different places, thus require two different <code>queryBuilders</code>.</p>

<p>On one place I need the method to use this <code>queryBuilder</code>;</p>

<pre><code>$queryBuilder = $this-&gt;getConfigurationPool()-&gt;getContainer()-&gt;get('doctrine')-&gt;getManager('admin')-&gt;createQueryBuilder();
</code></pre>

<p>And somewhere else I need the <code>queryBuilder</code> to be this;</p>

<pre><code>$queryBuilder = $this-&gt;get('doctrine')-&gt;getManager('admin')-&gt;createQueryBuilder();
</code></pre>

<p>How can I accomplish this in the same method? Because the rest of it will be exactly the same if I made two different methods, and that feels unnecessary.</p>

<p>Something like, try this one and if not working catch and try the other one.</p>