1
votes

I'm trying to override a third party bundle's layout template with the layout of my bundle, by including the new layout in the app/Resources/ directory as indicated in the Symfony2 book section; however, I'm getting the following exception:

"...path_to_my_app/app/Resources/FOSUserBundle/views/layout.html.twig" resource is hidden by a resource from the "MyVendorMyBundle" derived bundle. Create a "...path_to_my_app/app/Resources/MyVendorMyBundle/views/layout.html.twig" file to override the bundle resource.

In particular, I would like to overwrite the FOSUserBundle layout with that in my bundle. I followed the steps shown in the bundle's documentation, which are no different than those in the Symfony book.

What could be the cause of this exception? and how can I make it work?

I tried putting my bundle's layout in the app/Resources/MyVendorMyBundle/views/ as indicated in the above exception message, but if I do that, only the layout of MyBundle is read and returned and not the templates for the FOSUserBundle that extend it.

1

1 Answers

3
votes

Turns out the developer that preceded me had set MyBundle as a child of FOSUserBundle as shown in the documentation (without me noticing...):

// src/Acme/UserBundle/AcmeUserBundle.php
namespace Acme\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeUserBundle extends Bundle
{
    public function getParent()
    {
        return 'FOSUserBundle';
    }
}

The above was obviously creating conflict with (hiding) the re-defined layout template in the app/Resources/FOSUserBundle/views/ folder. I just deleted the getParent() method from the above shown bundle class to solve the issue.