|
3 | 3 |
|
4 | 4 | In applications not using webpack add these two lines in your layout: |
5 | 5 |
|
6 | | -.. configuration-block:: |
| 6 | +**With Twig:** |
7 | 7 |
|
8 | | - .. code-block:: html+twig |
| 8 | +.. code-block:: twig |
9 | 9 |
|
10 | | - <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script> |
11 | | - <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script> |
| 10 | + <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script> |
| 11 | + <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script> |
12 | 12 |
|
13 | | - .. code-block:: html+php |
| 13 | +**With PHP:** |
14 | 14 |
|
15 | | - <script src="<?php echo $view['assets']->getUrl('bundles/fosjsrouting/js/router.js') ?>"></script> |
16 | | - <script src="<?php echo $view['router']->generate('fos_js_routing_js', array('callback' => 'fos.Router.setData')) ?>"></script> |
| 15 | +.. code-block:: html+php |
| 16 | + |
| 17 | + <script src="<?php echo $view['assets']->getUrl('bundles/fosjsrouting/js/router.js') ?>"></script> |
| 18 | + <script src="<?php echo $view['router']->generate('fos_js_routing_js', array('callback' => 'fos.Router.setData')) ?>"></script> |
17 | 19 |
|
18 | 20 | .. note:: |
19 | 21 |
|
@@ -65,44 +67,46 @@ Or if you want to generate **absolute URLs**: |
65 | 67 |
|
66 | 68 | Assuming some route definitions: |
67 | 69 |
|
68 | | -.. configuration-block:: |
69 | | - |
70 | | - .. code-block:: php-annotations |
71 | | -
|
72 | | - // src/AppBundle/Controller/DefaultController.php |
73 | | -
|
74 | | - /** |
75 | | - * @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose") |
76 | | - */ |
77 | | - public function indexAction($foo) { |
78 | | - // ... |
79 | | - } |
80 | | -
|
81 | | - /** |
82 | | - * @Route("/blog/{page}", |
83 | | - * defaults = { "page" = 1 }, |
84 | | - * options = { "expose" = true }, |
85 | | - * name = "my_route_to_expose_with_defaults", |
86 | | - * ) |
87 | | - */ |
88 | | - public function blogAction($page) { |
89 | | - // ... |
90 | | - } |
91 | | -
|
92 | | - .. code-block:: yaml |
93 | | -
|
94 | | - # app/config/routing.yml |
95 | | - my_route_to_expose: |
96 | | - pattern: /foo/{id}/bar |
97 | | - defaults: { _controller: AppBundle:Default:index } |
98 | | - options: |
99 | | - expose: true |
100 | | -
|
101 | | - my_route_to_expose_with_defaults: |
102 | | - pattern: /blog/{page} |
103 | | - defaults: { _controller: AppBundle:Default:blog, page: 1 } |
104 | | - options: |
105 | | - expose: true |
| 70 | +**With annotations:** |
| 71 | + |
| 72 | +.. code-block:: php |
| 73 | +
|
| 74 | + // src/AppBundle/Controller/DefaultController.php |
| 75 | +
|
| 76 | + /** |
| 77 | + * @Route("/foo/{id}/bar", options={"expose"=true}, name="my_route_to_expose") |
| 78 | + */ |
| 79 | + public function indexAction($foo) { |
| 80 | + // ... |
| 81 | + } |
| 82 | +
|
| 83 | + /** |
| 84 | + * @Route("/blog/{page}", |
| 85 | + * defaults = { "page" = 1 }, |
| 86 | + * options = { "expose" = true }, |
| 87 | + * name = "my_route_to_expose_with_defaults", |
| 88 | + * ) |
| 89 | + */ |
| 90 | + public function blogAction($page) { |
| 91 | + // ... |
| 92 | + } |
| 93 | +
|
| 94 | +**With YAML:** |
| 95 | + |
| 96 | +.. code-block:: yaml |
| 97 | +
|
| 98 | + # app/config/routing.yml |
| 99 | + my_route_to_expose: |
| 100 | + pattern: /foo/{id}/bar |
| 101 | + defaults: { _controller: AppBundle:Default:index } |
| 102 | + options: |
| 103 | + expose: true |
| 104 | +
|
| 105 | + my_route_to_expose_with_defaults: |
| 106 | + pattern: /blog/{page} |
| 107 | + defaults: { _controller: AppBundle:Default:blog, page: 1 } |
| 108 | + options: |
| 109 | + expose: true |
106 | 110 |
|
107 | 111 | You can use the ``generate()`` method that way: |
108 | 112 |
|
|
0 commit comments