Skip to content

Commit

Permalink
Fix EZP-21786: Using Page fieldtype, valid block items should be pass…
Browse files Browse the repository at this point in the history
…ed to the block templates

See [EZP-21786](https://jira.ez.no/browse/EZP-21786).
This prevents fetch function revival when designing frontpages with Page fieldtype.

Note that PageService injection in template is kept for BC sake. To be removed in v6.0
  • Loading branch information
lolautruche committed Oct 18, 2013
1 parent 828b015 commit 3738718
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/bc/changes-5.2.md
Expand Up @@ -42,6 +42,10 @@ Changes affecting version compatibility with former or future versions.
As explained in API, the 'path' property for those classes is deprecated,
and 'id' should be used instead.

* PageController::viewBlock()

`pageService` injection will be removed in v6.0. See https://jira.ez.no/browse/EZP-21786.

## Removals

### API
Expand Down
31 changes: 31 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/Controller/PageController.php
@@ -0,0 +1,31 @@
<?php
/**
* File containing the PageController class.
*
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
*/

namespace eZ\Bundle\EzPublishCoreBundle\Controller;

use eZ\Bundle\EzPublishCoreBundle\FieldType\Page\PageService as CoreBundlePageService;
use eZ\Publish\Core\FieldType\Page\Parts\Block;
use eZ\Publish\Core\MVC\Symfony\Controller\PageController as BasePageController;
use Symfony\Component\HttpFoundation\Response;

class PageController extends BasePageController
{
public function viewBlock( Block $block, array $params = array(), array $cacheSettings = array() )
{
// Inject valid items as ContentInfo objects if possible.
if ( $this->pageService instanceof CoreBundlePageService )
{
$params += array(
'valid_contentinfo_items' => $this->pageService->getValidBlockItemsAsContentInfo( $block )
);
}

return parent::viewBlock( $block, $params, $cacheSettings );
}
}
Expand Up @@ -6,7 +6,7 @@ parameters:
ezpublish.config.default_scope: ezsettings
ezpublish.controller.base.class: eZ\Publish\Core\MVC\Symfony\Controller\Controller
ezpublish.controller.content.view.class: eZ\Publish\Core\MVC\Symfony\Controller\Content\ViewController
ezpublish.controller.page.view.class: eZ\Publish\Core\MVC\Symfony\Controller\PageController
ezpublish.controller.page.view.class: eZ\Bundle\EzPublishCoreBundle\Controller\PageController
ezpublish.data_collector.spi.persistence.class: eZ\Bundle\EzPublishCoreBundle\Collector\SPIPersistenceDataCollector
ezpublish.controller.user.authentication.class: eZ\Publish\Core\MVC\Symfony\Controller\User\AuthenticationController

Expand Down
8 changes: 6 additions & 2 deletions eZ/Publish/Core/MVC/Symfony/Controller/PageController.php
Expand Up @@ -24,7 +24,7 @@ class PageController extends Controller
/**
* @var \eZ\Publish\Core\FieldType\Page\PageService
*/
private $pageService;
protected $pageService;

public function __construct( ViewManager $viewManager, PageService $pageService )
{
Expand Down Expand Up @@ -67,7 +67,11 @@ public function viewBlock( Block $block, array $params = array(), array $cacheSe
$response->setContent(
$this->viewManager->renderBlock(
$block,
$params + array( 'pageService' => $this->pageService )
$params + array(
// @deprecated pageService injection will be removed in 6.0.
'pageService' => $this->pageService,
'valid_items' => $this->pageService->getValidBlockItems( $block )
)
)
);
return $response;
Expand Down

0 comments on commit 3738718

Please sign in to comment.