forked from lolautruche/EzCoreExtraBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lolautruche#39: Configurable view don't have current content/loca…
…tion any more
- Loading branch information
1 parent
cec1bff
commit 8f172ac
Showing
4 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# UPGRADE FROM 2.x to 3.0 | ||
|
||
## Template variables injection | ||
### View parameter providers | ||
|
||
#### Access to `content` and `location` | ||
Access to current `Content` and `Location` objects have changed. | ||
They're now available via `ConfigurableView::getContent()` and `ConfigurableView::getLocation`. | ||
|
||
**Before** | ||
|
||
```php | ||
class MyParamProvider | ||
{ | ||
public function getParameters(ConfigurableView $view, array $options = []) | ||
{ | ||
// Current location and content are available in content/location views | ||
$location = $view->getParameter('content'); | ||
$content = $view->getParameter('location'); | ||
|
||
// Passed options | ||
$contentTypeForChildren = $options['children_type']; | ||
$childrenLimit = $options['children_limit']; | ||
// Fetch children with those options | ||
// $fetchedChildren = ... | ||
|
||
return array( | ||
'foo' => $this->someService->giveMeFoo(), | ||
'some' => 'thing', | ||
'children' => $fetchedChildren, | ||
); | ||
} | ||
}} | ||
``` | ||
|
||
**After** | ||
|
||
```php | ||
class MyParamProvider | ||
{ | ||
public function getParameters(ConfigurableView $view, array $options = []) | ||
{ | ||
// Current location and content are available in content/location views | ||
$location = $view->getContent(); | ||
$content = $view->getLocation(); | ||
|
||
// Passed options | ||
$contentTypeForChildren = $options['children_type']; | ||
$childrenLimit = $options['children_limit']; | ||
// Fetch children with those options | ||
// $fetchedChildren = ... | ||
|
||
return array( | ||
'foo' => $this->someService->giveMeFoo(), | ||
'some' => 'thing', | ||
'children' => $fetchedChildren, | ||
); | ||
} | ||
}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters