Skip to content

do not rename the template in dynamic router #388

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 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

* **2017-02-06**: [BC BREAK] The `_template` request parameter will be renamed
to the `template` attribute instead of the `contentTemplate` attribute. The
old attribute will still be available for backwards compatibility.
* **2017-02-03**: [BC BREAK] Removed unused `cmf_routing.dynamic.persistence.phpcr.content_basepath`

2.0.0-RC1
Expand Down
58 changes: 46 additions & 12 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- Symfony\Cmf\Component\Routing\RouteReferrersReadInterface
```

After:
After:

```yaml
# app/config/config.yml
Expand Down Expand Up @@ -53,7 +53,7 @@
- cmf_routing.redirect_route_admin
```

After:
After:

```yaml
# app/config/config.yml
Expand All @@ -70,7 +70,8 @@

* The settings `admin_basepath` and `content_basepath` are only relevant for the admin and thus have been moved as well.

**Before**
Before:

```yaml
cmf_routing:
# ...
Expand All @@ -93,7 +94,8 @@
</config>
```

**After**
After:

```yaml
cmf_sonata_phpcr_admin_integration:
# ...
Expand All @@ -113,14 +115,15 @@
</config>
```

## Route Model
### Route Model

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

**Before**
Before:

```php
$route->setAddFormatPattern(true);
$route->setAddTrailingSlash(true);
Expand All @@ -130,7 +133,8 @@
}
```

**After**
After:

```php
$route->setOption('add_format_pattern', true);
$route->setOption('add_trailing_slash', true);
Expand All @@ -143,23 +147,26 @@
* Removed `getParent()`/`setParent()` from PHPCR `Route` and `RedirectRoute`.
Use `getParentDocument()`/`setParentDocument()` instead.

**Before**
Before:

```php
$route = new Route();
$route->setParent($routeRoot);
```

**After**
After:

```php
$route = new Route();
$route->setParentDocument($routeRoot);
```

## Configuration
### Configuration

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

**Before**
Before:

```yaml
cmf_routing:
# ...
Expand All @@ -178,7 +185,8 @@
</config>
```

**After**
After:

```yaml
cmf_routing:
# ...
Expand All @@ -198,3 +206,29 @@
</dynamic>
</config>
```

### Route Template

* The `contentTemplate` request attribute is deprecated in favor of
`template`. The CmfContentBundle has been adjusted accordingly.

Before:

```php
public function documentAction($contentDocument, $contentTemplate)
{
// ...
}
```

After:

```php
public function documentAction($contentDocument, $template)
{
// ...
}
```

The deprecated `contentTemplate` will be kept for backwards compatibility
and will be removed in version 3.0.
6 changes: 5 additions & 1 deletion src/Routing/DynamicRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DynamicRouter extends BaseDynamicRouter
* key for the request attribute that contains the template this document
* wants to use.
*/
const CONTENT_TEMPLATE = 'contentTemplate';
const CONTENT_TEMPLATE = 'template';

/**
* @var Request
Expand Down Expand Up @@ -99,6 +99,10 @@ protected function cleanDefaults($defaults, Request $request = null)

if (array_key_exists(RouteObjectInterface::TEMPLATE_NAME, $defaults)) {
$request->attributes->set(self::CONTENT_TEMPLATE, $defaults[RouteObjectInterface::TEMPLATE_NAME]);

// contentTemplate is deprecated as of version 2.0, to be removed in 3.0
$request->attributes->set('contentTemplate', $defaults[RouteObjectInterface::TEMPLATE_NAME]);

unset($defaults[RouteObjectInterface::TEMPLATE_NAME]);
}

Expand Down