Skip to content

Commit 23631d7

Browse files
authored
Merge pull request #388 from symfony-cmf/not-rename-template
do not rename the template in dynamic router
2 parents 926de06 + 8ebb686 commit 23631d7

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
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 `_template` request parameter will be renamed
5+
to the `template` attribute instead of the `contentTemplate` attribute. The
6+
old attribute will still be available for backwards compatibility.
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: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- Symfony\Cmf\Component\Routing\RouteReferrersReadInterface
2222
```
2323
24-
After:
24+
After:
2525
2626
```yaml
2727
# app/config/config.yml
@@ -53,7 +53,7 @@
5353
- cmf_routing.redirect_route_admin
5454
```
5555
56-
After:
56+
After:
5757
5858
```yaml
5959
# app/config/config.yml
@@ -70,7 +70,8 @@
7070
7171
* The settings `admin_basepath` and `content_basepath` are only relevant for the admin and thus have been moved as well.
7272

73-
**Before**
73+
Before:
74+
7475
```yaml
7576
cmf_routing:
7677
# ...
@@ -93,7 +94,8 @@
9394
</config>
9495
```
9596

96-
**After**
97+
After:
98+
9799
```yaml
98100
cmf_sonata_phpcr_admin_integration:
99101
# ...
@@ -113,14 +115,15 @@
113115
</config>
114116
```
115117

116-
## Route Model
118+
### Route Model
117119

118120
* Removed `getAddFormatPattern()`/`setAddFormatPattern()` from the model
119121
`Route` and `getAddTrailingSlash()`/`setAddTrailingSlash()` from the PHPCR
120122
`Route`. Use `getOption()`/`setOption()` with `'add_format_pattern'` or
121123
`'add_trailing_slash'` instead.
122124

123-
**Before**
125+
Before:
126+
124127
```php
125128
$route->setAddFormatPattern(true);
126129
$route->setAddTrailingSlash(true);
@@ -130,7 +133,8 @@
130133
}
131134
```
132135

133-
**After**
136+
After:
137+
134138
```php
135139
$route->setOption('add_format_pattern', true);
136140
$route->setOption('add_trailing_slash', true);
@@ -143,23 +147,26 @@
143147
* Removed `getParent()`/`setParent()` from PHPCR `Route` and `RedirectRoute`.
144148
Use `getParentDocument()`/`setParentDocument()` instead.
145149

146-
**Before**
150+
Before:
151+
147152
```php
148153
$route = new Route();
149154
$route->setParent($routeRoot);
150155
```
151156

152-
**After**
157+
After:
158+
153159
```php
154160
$route = new Route();
155161
$route->setParentDocument($routeRoot);
156162
```
157163

158-
## Configuration
164+
### Configuration
159165

160166
* Removed the `route_basepath` setting, use `route_basepaths` instead.
161167

162-
**Before**
168+
Before:
169+
163170
```yaml
164171
cmf_routing:
165172
# ...
@@ -178,7 +185,8 @@
178185
</config>
179186
```
180187

181-
**After**
188+
After:
189+
182190
```yaml
183191
cmf_routing:
184192
# ...
@@ -198,3 +206,29 @@
198206
</dynamic>
199207
</config>
200208
```
209+
210+
### Route Template
211+
212+
* The `contentTemplate` request attribute is deprecated in favor of
213+
`template`. The CmfContentBundle has been adjusted accordingly.
214+
215+
Before:
216+
217+
```php
218+
public function documentAction($contentDocument, $contentTemplate)
219+
{
220+
// ...
221+
}
222+
```
223+
224+
After:
225+
226+
```php
227+
public function documentAction($contentDocument, $template)
228+
{
229+
// ...
230+
}
231+
```
232+
233+
The deprecated `contentTemplate` will be kept for backwards compatibility
234+
and will be removed in version 3.0.

src/Routing/DynamicRouter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ 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';
4545

4646
/**
4747
* @var Request
@@ -99,6 +99,10 @@ protected function cleanDefaults($defaults, Request $request = null)
9999

100100
if (array_key_exists(RouteObjectInterface::TEMPLATE_NAME, $defaults)) {
101101
$request->attributes->set(self::CONTENT_TEMPLATE, $defaults[RouteObjectInterface::TEMPLATE_NAME]);
102+
103+
// contentTemplate is deprecated as of version 2.0, to be removed in 3.0
104+
$request->attributes->set('contentTemplate', $defaults[RouteObjectInterface::TEMPLATE_NAME]);
105+
102106
unset($defaults[RouteObjectInterface::TEMPLATE_NAME]);
103107
}
104108

0 commit comments

Comments
 (0)