I try to figure out how to get a Bundle Template inheritation/override with Symfony.
I am aware about the Documentation: https://symfony.com/doc/current/bundles/override.html#override-templates
Thats´s so far clear and works as expected.
But, i create a own Bundle which inherits as Dependency another Bundle with the goal to extend this.
Bundle A: Toolbox Bundle (Templates located in the Bundle in “templates” Folder and has config as well)
Bundle B: My own Bootstrap Bundle (Templates located in the Bundle in “templates” Folder)
what i do is this:
class BootstrapBundle extends AbstractBundle implements PimcoreBundleInterface, DependentBundleInterface
{
...
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/services.yaml');
}
public static function registerDependentBundles(BundleCollection $collection): void
{
$collection->addBundle(new ToolboxBundle);
}
public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
{
// prepend config from a file
$container->import('../config/packages/toolbox.yaml');
}
...
}
Then i use my “Bootstrap” Bundle within my own Project, and – damn – it ignore the “templates” folder within my own Bundle. Only in my project files if i create a folder for override Templates it works, but it only “overrides” the original Template Path Parts.
My expectation was that Templates will we search in this order:
{current_project_dir}/templates/bundles/BootstrapBundle/...
{current_project_dir}/templates/bundles/ToolboxBundle/...
{vendor_bootstrap_bundle_dir}/templates/bundles/ToolboxBundle/...
{vendor_toolbox_bundle_dir}/templates/...
But it only searches:
{current_project_dir}/templates/bundles/ToolboxBundle/...
{vendor_toolbox_bundle_dir}/templates/...
Looks i made something wrong within my Bundle or it isn´t possible to achive such a inerhitation from Bundle Templates