symfony/demo

Don't use Twig CodeExtension helpers outside of a profiler panel

GromNaN opened this issue · 2 comments

The CodeExtension Twig extension moved to the WebProfilerBundle symfony/symfony#52483.

This extension should only be used for debugging tools code that is never executed in a production environment.

This demo uses the format_file helper even in prod environment.

<p class="file-link">{{ controller.file_path|format_file(controller.starting_line) }}</p>

Even if it's very convenient and specific to this demo, we'd have to find another solution.

Demo needs to adjust, we don't want to support such use cases.
symfony/symfony#52531 (comment)

stof commented

This demo could create its own filter demo_format_file copying the implementation from the core if needed, with a big warning on that class telling that you should not actually deploy this in a production project. This should go in the existing SourceCodeExtension of the demo.

I added the helper to the existing SourceCodeExtension, which already has a warning comment. #1456