Skip to content

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

@umpirsky

Description

@umpirsky
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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy