File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed
components/expression_language Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -127,9 +127,16 @@ Working with Functions
127
127
----------------------
128
128
129
129
You can also use registered functions in the expression by using the same
130
- syntax as PHP and JavaScript. The ExpressionLanguage component comes with one
131
- function by default: ``constant() ``, which will return the value of the PHP
132
- constant::
130
+ syntax as PHP and JavaScript. The ExpressionLanguage component comes with the
131
+ following functions by default:
132
+
133
+ * ``constant() ``
134
+ * ``enum() ``
135
+
136
+ Constant function
137
+ ~~~~~~~~~~~~~~~~~
138
+
139
+ This function will return the value of the PHP constant::
133
140
134
141
define('DB_USER', 'root');
135
142
@@ -139,6 +146,26 @@ constant::
139
146
140
147
This will print out ``root ``.
141
148
149
+ Enum function
150
+ ~~~~~~~~~~~~~
151
+
152
+ This function will return the case of an enumeration::
153
+
154
+ enum Foo
155
+ {
156
+ case Bar;
157
+ }
158
+
159
+ var_dump(App\Enum\Foo::Bar === $expressionLanguage->evaluate(
160
+ 'enum("App\\\Enum\\\Foo::Bar")'
161
+ ));
162
+
163
+ This will print out ``true ``.
164
+
165
+ .. versionadded :: 6.3
166
+
167
+ The ``enum() `` function was introduced in Symfony 6.3.
168
+
142
169
.. tip ::
143
170
144
171
To read how to register your own functions to use in an expression, see
You can’t perform that action at this time.
0 commit comments