Symfony2 use getDoctrine() in AppKernel to dynamically register bundles <p>I have created an application where I can manage multiple websites. There are a lot of "extensions" (bundles) that can be used in the websites if they have the right to use it. The rights (which website can use wich bundles) are managed in my application and are saved in the database (with the namespace of the allowed bundle). </p> <p><strong>EDIT:</strong> <strike>When I call a website the bundles are loaded in the WebsiteKernel (a normal AppKernel that is commonly used by each website).</strike> <em>Each website has its's own app- and web-folder. So there is a separate app-cache for each website. Each website has it's own WebsiteKernel.php (= a normal AppKernel).</em></p> <p>Now I want to register the allowed bundles for the currently called website dynamically in <strike>the</strike> <em>its</em> WebsiteKernel. In the post "<a href="http://stackoverflow.com/questions/6609240/is-it-possible-to-dynamically-register-bundles-in-symfony2">Is it possible to dynamically register bundles in Symfony2?</a>" this was done by looking into the bundle-directories. I would like to do this the same way but I only want to include the bundles that are saved as "allowed for this website" in the database.</p> <p>To do so I need access to a repository to get the allowed bundle-namespaces. I thought I could do something like <code>$this-&gt;getDoctrine()-&gt;getRepository('MyAppBundle:MyObject');</code> but I don't know how to call this function in the WebsiteKernel (= AppKernel). When I try to call <code>$this-&gt;getDoctrine()</code> I have a UndefinedMethodExeption. Of course I try to do this after the doctrine-bundle has been registered.</p> <p><strong>So the question is: How do I have to change the code in the WebsiteKernel (= AppKernel) to use <code>$this-&gt;getDoctrine()</code>?</strong></p> <p>Btw.: This two posts have a similar problem but they hasn't been answered yet.</p> <ul> <li><a href="http://stackoverflow.com/questions/10572966/symfony2-how-to-dynamically-register-a-bundle-and-clear-the-cache-from-other">Symfony2: How to dynamically register a bundle (and clear the cache) from other bundle&#39;s controller</a></li> <li><a href="http://stackoverflow.com/questions/10060282/symfony2-register-bundle-and-its-routes-at-runtime">Symfony2 register bundle and its routes at runtime</a></li> </ul>