Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,9 @@ Checking if a Template Exists
Templates are loaded in the application using a `Twig template loader`_, which
also provides a method to check for template existence. First, get the loader::

// in a controller extending from AbstractController
$loader = $this->get('twig')->getLoader();

// in a service using autowiring
use Twig\Environment;

// this code assumes that your service uses autowiring to inject dependencies
Copy link
Member

Choose a reason for hiding this comment

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

I think it's good to mention the service ID in this comment in case someone isn't (yet) using auto wiring

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I did that while merging. Thanks.

public function __construct(Environment $twig)
{
$loader = $twig->getLoader();
Expand Down