Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Twig as a First-Class Citizen and final ControllerTrait::render() #26255

Copy link
Copy link
@umpirsky

Description

@umpirsky
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? yes
RFC? yes
Symfony version 3.4.4

As described in http://symfony.com/blog/new-in-symfony-2-7-twig-as-a-first-class-citizen#what-about-performance, there is a performance penalty when using templating sub-system.

ControllerTrait::render() tries to render with templating first, but one can optimize controllers by overriding it in base controller like:

public function render($view, array $parameters = [], Response $response = null)
{
    if (null === $response) {
        $response = new Response();
    }

    $response->setContent($this->get('twig')->render($view, $parameters));

    return $response;
}

The method ControllerTrait::render() is considered final since version 3.4, so it cannot be overridden any more, and this optimization is no longer possible.

One possibility can be:

templating:
        enabled: false

but that can cause issues with some third party code that rely on templating service.

So basically what I am trying to accomplish is to keep this optimization possible for controllers.

One idea was to try twig first in ControllerTrait::render(), but that would probably break in some cases.

So, is there a workaround I am not aware of, or is there something we can do to allow this kind of optimizations in future versions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.