Skip to content

added Twig runtimes for "critical" Twig extensions #20094

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 5 commits into from
Sep 30, 2016

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Sep 29, 2016

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

This PR converts some Twig extensions to use a separate runtime. It also contains some optimizations to not load extensions when the associated component is not installed.

*
* @see FragmentHandler::render()
*/
public function renderFragment($uri, $options = array())
Copy link
Contributor

Choose a reason for hiding this comment

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

While I agree with this change, it might break hacky solutions that wrap around this using decorators or extending this extension.

Twig extensions are not explicitly mentioned in the BC promises but should imo be considered internal (thus would allow this change)

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's be pragmatic here. This is definitely not an extension point.

*
* @author Fabien Potencier <fabien@symfony.com>
*/
class HttpKernelRuntime
Copy link
Contributor

Choose a reason for hiding this comment

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

As usual: any reason to allow inheritance?

{
return $this->handler->render($uri, $strategy, $options);
}

public function controller($controller, $attributes = array(), $query = array())
Copy link
Member

Choose a reason for hiding this comment

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

if we want to optimize even further, we could turn such methods into static methods

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

@@ -71,5 +71,17 @@ public function process(ContainerBuilder $container)
if ($container->has('assets.packages')) {
$container->getDefinition('twig.extension.assets')->addTag('twig.extension');
}

if (class_exists('Symfony\Component\Yaml\Parser')) {
Copy link
Member

Choose a reason for hiding this comment

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

As the definition of the container now depends on the existence of a class, we should define a ClassExistenceResource and add such a resource to the container for such patterns (outside the if), so that the debug container is reloaded if you install the class

Copy link
Member Author

Choose a reason for hiding this comment

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

That's for another PR as this is not the only place where we are doing this in a compiler pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

see #20121

@fabpot fabpot merged commit c541804 into symfony:master Sep 30, 2016
fabpot added a commit that referenced this pull request Sep 30, 2016
…bpot)

This PR was merged into the 3.2-dev branch.

Discussion
----------

added Twig runtimes for "critical" Twig extensions

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

This PR converts some Twig extensions to use a separate runtime. It also contains some optimizations to not load extensions when the associated component is not installed.

Commits
-------

c541804 fixed tests
812fbb4 decoupled the Twig HttpKernelExtension runtime from the extension
79efb4c [TwigBundle] removed ExpressionLanguage Twig extension when the ExpressionLanguage component is not available
3d4ad0b [TwigBundle] removed Stopwatch Twig extension when the Stopwatch component is not available
d0792e4 [TwigBundle] removed YAML Twig extension when the YAML component is not available
@fabpot fabpot deleted the twig-runtimes branch October 1, 2016 05:07
@fabpot fabpot mentioned this pull request Oct 1, 2016
fabpot added a commit that referenced this pull request Oct 5, 2016
This PR was merged into the 3.2-dev branch.

Discussion
----------

Class existence resource

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

Commits
-------

222b56d [TwigBundle] added support for ClassExistenceResource when relevant
d98eb7b [Config] added ClassExistenceResource
@fabpot fabpot mentioned this pull request Oct 27, 2016
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.

6 participants