Skip to content

[HttpKernel] Remove bundle inheritance #24161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2017

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Sep 11, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

Blocked by #24160

@fabpot fabpot force-pushed the bundle-inheritance-removal branch 2 times, most recently from e557cf6 to 2186261 Compare September 11, 2017 21:15
@nicolas-grekas nicolas-grekas modified the milestones: 2.7, 3.4, 4.0 Sep 12, 2017
@xabbuh
Copy link
Member

xabbuh commented Sep 12, 2017

The TwigBundle also deals with the bundle hierarchy when resolving paths for bundle templates: https://github.com/fabpot/symfony/blob/218626157e915f4e26cc8bb619637248c0008c72/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php#L164-L214 I bet we can simplify a lot of code there too.

@fabpot fabpot force-pushed the bundle-inheritance-removal branch 3 times, most recently from 080f83e to 9ca264c Compare September 15, 2017 16:55
@fabpot
Copy link
Member Author

fabpot commented Sep 15, 2017

@xabbuh now removed

@@ -169,55 +160,21 @@ public function load(array $configs, ContainerBuilder $container)
private function getBundleHierarchy(ContainerBuilder $container, array $config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This inner code can be moved out safely, there is not much logic to encapsulate now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I prefer to keep it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update the method name? Maybe getBundleTemplatePaths() or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fabpot fabpot force-pushed the bundle-inheritance-removal branch 4 times, most recently from 737e1da to cd48de9 Compare September 15, 2017 18:26
@@ -166,58 +157,24 @@ public function load(array $configs, ContainerBuilder $container)
$container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime');
}

private function getBundleHierarchy(ContainerBuilder $container, array $config)
private function getBundleTemplatePaths(ContainerBuilder $container, array $config)
{
$bundleHierarchy = array();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe variable should be renamed in conformity with method name change?

@fabpot
Copy link
Member Author

fabpot commented Sep 21, 2017

Tests are green now!

/**
* @group legacy
* @expectedException \LogicException
* @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that test is still relevant and should be kept as it is not related to bundle inheritance

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I will fix it in 3.4 as this should not be deprecated there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to remove the legacy annotation in 3.4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @group annotation will be removed in #24364.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#24364 is for master. I don't see how this is related to this 3.4 issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fails with a deprecation on 3.4 otherwise.

@fabpot fabpot force-pushed the bundle-inheritance-removal branch from b8639ee to 7f8b86c Compare September 26, 2017 06:23
@fabpot fabpot force-pushed the bundle-inheritance-removal branch from 2704c39 to a8a0a21 Compare September 26, 2017 23:00
@fabpot fabpot merged commit a8a0a21 into symfony:master Sep 26, 2017
fabpot added a commit that referenced this pull request Sep 26, 2017
This PR was merged into the 4.0-dev branch.

Discussion
----------

[HttpKernel] Remove bundle inheritance

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Blocked by #24160

Commits
-------

a8a0a21 [HttpKernel] removed bundle inheritance
fabpot added a commit that referenced this pull request Sep 29, 2017
…s (yceruto)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBundle] Improve the overriding of bundle templates

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17557
| License       | MIT
| Doc PR        | -

### [Overriding a Template that also extends itself](https://twig.symfony.com/doc/2.x/recipes.html#overriding-a-template-that-also-extends-itself)

Now that bundles inheritance is deprecated and removed (#24160, #24161), I'm wondering if we can solve this old issue defining an exclusive namespace only for root bundles in `3.4` just bundles in `4.0`:
```yaml
twig:
    paths:
        # adding paths behind the scene into TwigExtension
        app/Resources/FooBundle/views: Foo
        vendor/acme/foo-bundle/Resources/views: Foo
        vendor/acme/foo-bundle/Resources/views: !Foo # exclusive
```
Thus, one can decide when use the exclusive namespace to avoid the issue and then [we could to say also](http://symfony.com/doc/current/templating/overriding.html):

> To override the bundle template partially (which contains `block`) creates a new `index.html.twig` template in `app/Resources/AcmeBlogBundle/views/Blog/index.html.twig` and extends from `@!AcmeBlogBundle/Blog/index.html.twig` to customize the bundle template:

```twig
{# app/Resources/FooBundle/views/layout.html.twig #}

{# this does not work: circular reference to itself #}
{% extends '@Foo/layout.html.twig' %}

{# this will work: load bundle layout template #}
{% extends '@!Foo/layout.html.twig' %}

{% block title 'New title' %}
```
I hear other suggestions about the excluse namespace.

We will need to update http://symfony.com/doc/current/templating.html#referencing-templates-in-a-bundle too to add this convention.

WDYT?

Commits
-------

0a658c6 Add exclusive Twig namespace for bundles path
@fabpot fabpot mentioned this pull request Oct 19, 2017
@fabpot fabpot deleted the bundle-inheritance-removal branch January 14, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants