Document storing an enum in a variable to avoid repeating its FQCN

This commit is contained in:
Fabien Potencier
2026-06-03 21:58:29 +02:00
parent 1a2f2ea0a3
commit e1178abfa1
+9
View File
@@ -32,6 +32,15 @@
When using a string literal for the ``enum`` argument, it will be validated during compile time to be a valid enum name.
As the FQCN can be long, you can store the enum in a variable to avoid repeating
it:
.. code-block:: twig
{% set suite = enum('App\\CardSuite') %}
{{ suite.Clubs.value }} {# "clubs" #}
{{ suite.Spades.value }} {# "spades" #}
Arguments
---------