@@ -370,6 +370,8 @@ arbitrary matching logic:
370
370
condition : " context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
371
371
# expressions can also include configuration parameters:
372
372
# condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'"
373
+ # expressions can even use environment variables:
374
+ # condition: "context.getHost() == env('APP_MAIN_HOST')"
373
375
374
376
.. code-block :: xml
375
377
@@ -384,6 +386,8 @@ arbitrary matching logic:
384
386
<condition >context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'</condition >
385
387
<!-- expressions can also include configuration parameters: -->
386
388
<!-- <condition>request.headers.get('User-Agent') matches '%app.allowed_browsers%'</condition> -->
389
+ <!-- expressions can even use environment variables: -->
390
+ <!-- <condition>context.getHost() == env('APP_MAIN_HOST')</condition> -->
387
391
</route >
388
392
</routes >
389
393
@@ -398,7 +402,9 @@ arbitrary matching logic:
398
402
->controller([DefaultController::class, 'contact'])
399
403
->condition('context.getMethod() in ["GET", "HEAD"] and request.headers.get("User-Agent") matches "/firefox/i"')
400
404
// expressions can also include configuration parameters:
401
- // 'request.headers.get("User-Agent") matches "%app.allowed_browsers%"'
405
+ // ->condition('request.headers.get("User-Agent") matches "%app.allowed_browsers%"')
406
+ // expressions can even use environment variables:
407
+ // ->condition('context.getHost() == env("APP_MAIN_HOST")')
402
408
;
403
409
};
404
410
@@ -414,10 +420,10 @@ and can use any of these variables created by Symfony:
414
420
The :ref: `Symfony Request <component-http-foundation-request >` object that
415
421
represents the current request.
416
422
417
- Additionnal functions are provided :
423
+ You can also use this function :
418
424
419
425
``env(string $name) ``
420
- Read a variable using :doc: `Environment Variable Processors <configuration/env_var_processors >`
426
+ Returns the value of a variable using :doc: `Environment Variable Processors <configuration/env_var_processors >`
421
427
422
428
Behind the scenes, expressions are compiled down to raw PHP. Because of this,
423
429
using the ``condition `` key causes no extra overhead beyond the time it takes
0 commit comments