Skip to content
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

[TwigBundle][DX] Only add the Twig WebLinkExtension if the WebLink component is enabled #27626

Merged
merged 1 commit into from
Jun 25, 2018

Conversation

thewilkybarkid
Copy link
Contributor

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

While adding elifesciences/journal#990 I was a bit confused why the preload() Twig function didn't work initially. Turns out the WebLink component is disabled by default if using the full stack, but the Twig extension is always enabled.

This only adds the Twig extension if the component is enabled, and shows a friendly error message if it's not.

@carsonbot carsonbot added Status: Needs Review TwigBundle DX DX = Developer eXperience (anything that improves the experience of using Symfony) Bug labels Jun 18, 2018
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jun 19, 2018
@@ -71,6 +72,10 @@ public static function onUndefinedFunction($name)
return false;
}

if (\class_exists(FullStack::class) && 'web-link' === self::$functionComponents[$name]) {
Copy link
Member

Choose a reason for hiding this comment

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

what about other components needing to be enabled ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the other functions/filters?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, you add a special error message for the full stack case here when forgetting to enable a component (while the previous error message was for the non-fullstack case to tell to install a package). But web-link is not the only component needing to be enabled explicitly in a fullstack project. If we start to handled this case with nicer error messages, we should do it for all components, not only for one.

'security-core' => 'add the "SecurityBundle"',
'security-http' => 'add the "SecurityBundle"',
'web-link' => 'enable "framework.web_link"',
'workflow' => 'enable "framework.workflows"',
Copy link
Contributor Author

@thewilkybarkid thewilkybarkid Jun 20, 2018

Choose a reason for hiding this comment

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

I think these are right, and the only ones effected.

@fabpot
Copy link
Member

fabpot commented Jun 25, 2018

Thank you @thewilkybarkid.

@fabpot fabpot merged commit cccb66f into symfony:3.4 Jun 25, 2018
fabpot added a commit that referenced this pull request Jun 25, 2018
… WebLink component is enabled (thewilkybarkid)

This PR was squashed before being merged into the 3.4 branch (closes #27626).

Discussion
----------

[TwigBundle][DX] Only add the Twig WebLinkExtension if the WebLink component is enabled

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

While adding elifesciences/journal#990 I was a bit confused why the `preload()` Twig function didn't work initially. Turns out the WebLink component is disabled by default if using the full stack, but the Twig extension is always enabled.

This only adds the Twig extension if the component is enabled, and shows a friendly error message if it's not.

Commits
-------

cccb66f [TwigBundle][DX] Only add the Twig WebLinkExtension if the WebLink component is enabled
@thewilkybarkid thewilkybarkid deleted the twig-web-link branch June 25, 2018 11:36
This was referenced Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DX DX = Developer eXperience (anything that improves the experience of using Symfony) Status: Reviewed TwigBundle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants