Skip to content

Commit a44de02

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Add missing signature_properties config Documentation for env() function in route condition
2 parents d9d195f + 5e159d7 commit a44de02

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

routing.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ arbitrary matching logic:
364364
condition: "context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
365365
# expressions can also include configuration parameters:
366366
# condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'"
367+
# expressions can even use environment variables:
368+
# condition: "context.getHost() == env('APP_MAIN_HOST')"
367369
368370
.. code-block:: xml
369371
@@ -378,6 +380,8 @@ arbitrary matching logic:
378380
<condition>context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'</condition>
379381
<!-- expressions can also include configuration parameters: -->
380382
<!-- <condition>request.headers.get('User-Agent') matches '%app.allowed_browsers%'</condition> -->
383+
<!-- expressions can even use environment variables: -->
384+
<!-- <condition>context.getHost() == env('APP_MAIN_HOST')</condition> -->
381385
</route>
382386
</routes>
383387
@@ -392,7 +396,9 @@ arbitrary matching logic:
392396
->controller([DefaultController::class, 'contact'])
393397
->condition('context.getMethod() in ["GET", "HEAD"] and request.headers.get("User-Agent") matches "/firefox/i"')
394398
// expressions can also include configuration parameters:
395-
// 'request.headers.get("User-Agent") matches "%app.allowed_browsers%"'
399+
// ->condition('request.headers.get("User-Agent") matches "%app.allowed_browsers%"')
400+
// expressions can even use environment variables:
401+
// ->condition('context.getHost() == env("APP_MAIN_HOST")')
396402
;
397403
};
398404
@@ -408,6 +414,11 @@ and can use any of these variables created by Symfony:
408414
The :ref:`Symfony Request <component-http-foundation-request>` object that
409415
represents the current request.
410416

417+
You can also use this function:
418+
419+
``env(string $name)``
420+
Returns the value of a variable using :doc:`Environment Variable Processors <configuration/env_var_processors>`
421+
411422
Behind the scenes, expressions are compiled down to raw PHP. Because of this,
412423
using the ``condition`` key causes no extra overhead beyond the time it takes
413424
for the underlying PHP to execute.

security/login_link.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ under the firewall. You must configure a ``check_route`` and
6161
6262
<config>
6363
<firewall name="main">
64-
<login-link check-route="login_check"/>
64+
<login-link check-route="login_check">
65+
<signature-property>id</signature-property>
66+
</login-link>
6567
</firewall>
6668
</config>
6769
</srv:container>
@@ -75,6 +77,7 @@ under the firewall. You must configure a ``check_route`` and
7577
$security->firewall('main')
7678
->loginLink()
7779
->checkRoute('login_check')
80+
->signatureProperties(['id'])
7881
;
7982
};
8083

0 commit comments

Comments
 (0)