DrupalX

Extension
Framework

attributes

You can use the "attributes" method to access any request attribute by its key:

{% if Request->attributes("internal") %}
  <h1>Welcome to our intranet!</h1>
{% else %}
  <p>Sorry, this page is for internal use only.</p>  
{% endif %}

Request attributes are a special feature of the Symfony framework useful if you want to associate custom data with a request so that it is available throughout the application. It is one possible way of providing data from PHP to a Twig template that cannot be determined by the template itself.