Skip to content

Commit e3a2fa4

Browse files
gimlerxabbuh
authored andcommitted
add annotation block to routing conditions
1 parent db4f44d commit e3a2fa4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

routing/conditions.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ define arbitrary matching logic, use the ``conditions`` routing option:
1010

1111
.. configuration-block::
1212

13+
.. code-block:: php-annotations
14+
15+
// src/Controller/DefaultController.php
16+
namespace App\Controller;
17+
18+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
19+
use Symfony\Component\Routing\Annotation\Route;
20+
21+
class DefaultController extends AbstractController
22+
{
23+
/**
24+
* @Route(
25+
* "/contact",
26+
* name="contact",
27+
* condition="context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
28+
* )
29+
*
30+
* expressions can also include config parameters
31+
* condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'"
32+
*/
33+
public function contact()
34+
{
35+
// ...
36+
}
37+
}
38+
1339
.. code-block:: yaml
1440
1541
contact:

0 commit comments

Comments
 (0)