8000 Update conditions.rst by kockodev · Pull Request #10470 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Update conditions.rst #10470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions routing/conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ define arbitrary matching logic, use the ``conditions`` routing option:
path: /contact
controller: 'App\Controller\DefaultController::contact'
condition: "context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
# expressions can also include config parameters
# condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'"

.. code-block:: xml

Expand All @@ -30,6 +32,8 @@ define arbitrary matching logic, use the ``conditions`` routing option:
<route id="contact" path="/contact">
<default key="_controller">App\Controller\DefaultController::contact</default>
<condition>context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'</condition>
<!-- expressions can also include config parameters -->
<!-- <condition>request.headers.get('User-Agent') matches '%app.allowed_browsers%'</condition> -->
</route>
</routes>

Expand All @@ -50,6 +54,8 @@ define arbitrary matching logic, use the ``conditions`` routing option:
array(),
array(),
'context.getMethod() in ["GET", "HEAD"] and request.headers.get("User-Agent") matches "/firefox/i"'
// expressions can also include config parameters
// 'request.headers.get("User-Agent") matches "%app.allowed_browsers%"'
));

return $collection;
Expand Down
0