Skip to content

[HttpKernel] Deprecate bundle inheritance #24160

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 2 commits into from
Sep 15, 2017

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Sep 11, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #24048
License MIT
Doc PR symfony/symfony-docs#8389

@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from b02a36d to cad7f61 Compare September 11, 2017 18:39
@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from cad7f61 to 5f20b5c Compare September 11, 2017 18:42
@fabpot fabpot changed the base branch from master to 3.4 September 11, 2017 18:46
@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from 5f20b5c to aa56c12 Compare September 11, 2017 18:46
@@ -206,6 +206,10 @@ public function getBundles()
*/
public function getBundle($name, $first = true)
{
if (false === $first) {
@trigger_error(sprintf('Passing "false" as the second argument to %s() is deprecated as of 3.4 and will be removed in 4.0.', __METHOD_), E_USER_DEPRECATED);
Copy link
Contributor

@pierredup pierredup Sep 11, 2017

Choose a reason for hiding this comment

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

Typo, __METHOD_ should be __METHOD__

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from aa56c12 to 4f2beb9 Compare September 11, 2017 18:53
@@ -206,6 +206,10 @@ public function getBundles()
*/
public function getBundle($name, $first = true)
{
if (false === $first) {
Copy link
Contributor

Choose a reason for hiding this comment

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

at least locateResource is calling it with false.. should we get rid of $first there too? I believe it serves the same purpose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, fixed

@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch 5 times, most recently from 546a76f to 8fb7938 Compare September 11, 2017 19:50
@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from 8fb7938 to 9bb10fd Compare September 11, 2017 21:13
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Sep 12, 2017
@@ -204,8 +204,12 @@ public function getBundles()
/**
* {@inheritdoc}
*/
public function getBundle($name, $first = true)
public function getBundle($name, $first = true, $noDeprecation = false)
Copy link
Member

Choose a reason for hiding this comment

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

signature change should be removed, func_get_arg should be used instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -56,6 +56,8 @@ public function getContainerExtension();
* bundle.
*
* @return string The Bundle name it overrides or null if no parent
*
* @deprecated This method is deprecated as of 3.4 and will be removed in 4.0.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to drop the final dot here according to the latest CS changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Most @deprecated tags have a dot at the end currently. As this is a sentence, I think that's the way it should be.

@chalasr
Copy link
Member

chalasr commented Sep 12, 2017

Should we also deprecate Bundle::getParent() default implem before removing it?

@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch 2 times, most recently from d73a911 to 94707d2 Compare September 15, 2017 03:32
@fabpot
Copy link
Member Author

fabpot commented Sep 15, 2017

@chalasr Not sure it makes sense. This method is mainly called by Symfony itself, and if a bundle defines a parent, the message won't be displayed. So, it seems to me better to not add this.

@fabpot
Copy link
Member Author

fabpot commented Sep 15, 2017

RFR

@fabpot fabpot force-pushed the bundle-inheritance-deprecation branch from 94707d2 to 89893c1 Compare September 15, 2017 03:39
@fabpot fabpot merged commit 89893c1 into symfony:3.4 Sep 15, 2017
fabpot added a commit that referenced this pull request Sep 15, 2017
This PR was squashed before being merged into the 3.4 branch (closes #24160).

Discussion
----------

[HttpKernel] Deprecate bundle inheritance

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

Commits
-------

89893c1 [HttpKernel] deprecated bundle inheritance
ee9f4c3 fixed CS
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
This was referenced Oct 18, 2017
@fabpot fabpot deleted the bundle-inheritance-deprecation 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.

7 participants