Skip to content

Commit 65784fb

Browse files
committed
do not rename the template in dynamic router
$template is in line with the FrameworkBundle TemplateController
1 parent 926de06 commit 65784fb

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
=========
33

4+
* **2017-02-06**: [BC BREAK] The bundle dynamic router renames the `_template`
5+
parameter to `template` and not `contentTemplate` anymore. The parameter is
6+
still moved from the route defaults to the request attributes.
47
* **2017-02-03**: [BC BREAK] Removed unused `cmf_routing.dynamic.persistence.phpcr.content_basepath`
58

69
2.0.0-RC1

UPGRADE-2.0.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,24 @@
198198
</dynamic>
199199
</config>
200200
```
201+
202+
## Route Template
203+
204+
The `_template` parameter gets now renamed to `template`. The
205+
CmfContentBundle has been adjusted accordingly. If you have your own
206+
controllers that expect a template argument, adjust them accordingly:
207+
208+
**Before**
209+
```php
210+
public function documentAction($contentDocument, $contentTemplate) {
211+
...
212+
```
213+
214+
**After**
215+
```php
216+
public function documentAction($contentDocument, $template) {
217+
...
218+
```
219+
220+
For BC, version 2 of this bundle will still keep populating `contentTemplate` in
221+
addition to `template` but it is deprecated to rely on the `contentTemplate` field.

src/Routing/DynamicRouter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ class DynamicRouter extends BaseDynamicRouter
4141
* key for the request attribute that contains the template this document
4242
* wants to use.
4343
*/
44-
const CONTENT_TEMPLATE = 'contentTemplate';
44+
const CONTENT_TEMPLATE = 'template';
45+
46+
/**
47+
* RoutingBundle 1.* put the template into the request attributes as "contentTemplate".
48+
*
49+
* This name is deprecated in favor of "template" for consistency with
50+
* FrameworkBundle and will be removed in RoutingBundle 3.
51+
*/
52+
const BC_CONTENT_TEMPLATE = 'contentTemplate';
4553

4654
/**
4755
* @var Request
@@ -99,6 +107,7 @@ protected function cleanDefaults($defaults, Request $request = null)
99107

100108
if (array_key_exists(RouteObjectInterface::TEMPLATE_NAME, $defaults)) {
101109
$request->attributes->set(self::CONTENT_TEMPLATE, $defaults[RouteObjectInterface::TEMPLATE_NAME]);
110+
$request->attributes->set(self::BC_CONTENT_TEMPLATE, $defaults[RouteObjectInterface::TEMPLATE_NAME]);
102111
unset($defaults[RouteObjectInterface::TEMPLATE_NAME]);
103112
}
104113

0 commit comments

Comments
 (0)