0
votes

I have a third party bundle called VendorDeliveryBundle.

I want to override one of its twig templates that i called with this syntax in one of my App twig templates:
{% include '@VendorDelivery/Frontend/Booking/_delivery.html.twig' with { 'form': form } only %} Like this it works, the vendor template is called.

But if i want to override this template by registering the overriding bundle in AppKernel (as described in https://symfony.com/doc/2.8/bundles/inheritance.html) and by creating: App/DeliveryBundle/Resources/views/Frontend/Booking/_delivery.html.twig this template doesn't override the vendor template.

But if i use this syntax instead {% include 'VendorDeliveryBundle:Frontend:Booking/_delivery.html.twig' with { 'form': form } only %} the template is overridden.

It seems that the @ syntax doesn't work as expected.

So i'm wondering if it is a bug or a normal behavior considering this symfony documentation https://symfony.com/doc/2.8/bundles/inheritance.html:

The overriding of resources only works when you refer to resources with the @FOSUserBundle/Resources/config/routing/security.xml method. If you refer to resources without using the @BundleName shortcut, they can't be overridden in this way.

Thanks,

1

1 Answers

2
votes

@ in twig syntax is a feature called "namespaced paths". (documentation)

Use functionality of {% include 'Bundle:Folder:template' %} it is not the same thing as {% include '@Bundle\Folder\template' %}.

For sample, if you overriding fosub bundle:

{% include '@FOSUser/Security/login.html.twig' %} {# Will be fosub template #}
{% include '@User/Security/login.html.twig' %} {# Will be overrided template #}
{% include 'FOSUserBundle:Security:login.html.twig' %} {# Also will be overrided template #}

Also, i want to add, that if you want to override only a template (without global functionality as controllers, listeners, etc) you can added templates to you app directory. It is well described in this documentation