Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[TwigBundle] Default overriden bundle path should be processed in a compiler pass #30359

Copy link
Copy link
Closed
@alterphp

Description

@alterphp
Issue body actions

Symfony version(s) affected: 4.2

Description

  • I use EasyAdmin bundle for admin interfaces.
  • I also use an extension bundle alterphp/EasyAdminExtensionBundle that overrides all templates by adding its templates path to EasyAdmin namespace in a compiler pass.
  • Above this stack, I use another company-owned admin-bundle that also overrides EasyAdmin templates by adding its path to EasyAdmin namespace in a compiler pass.

The problem is that default overriden bundle path (`templates/bundles/EasyAdminBundle) comes "under" my 2 3rd party bundles overrides :
image

How to reproduce
In a symfony project with loaded EsayAdmin bundle for example, add the following CompilerPass to add the path of your choice in the EasyAdmin Twig namespace :

class TwigPathPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $twigLoaderFilesystemId = $container->getAlias('twig.loader')->__toString();
        $twigLoaderFilesystemDefinition = $container->getDefinition($twigLoaderFilesystemId);

        $twigLoaderFilesystemDefinition->addMethodCall('prependPath', array('templates/foo/bar', 'EasyAdmin'));
        }
    }
}

When dumping the paths for EasyAdmin namespaces, you can see that default overriden bundle path comes between original bundle path and your custom overriding path. This default overriden bundle path should, IMHO, comes above all third party bundles possible overrides.

dump($this->get('twig')->getLoader()->getPaths('EasyAdmin'));

image

Possible Solution
I think that processing this default overriden bundle path in a late compiler pass might resolve this problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.