-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #699 from ezsystems/fix_EZP-22239_previewContentSi…
…teaccessLegacyMode Fix EZP-22239: When the preview siteaccess runs in legacy mode, it falls...
- Loading branch information
Showing
6 changed files
with
209 additions
and
50 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
44 changes: 44 additions & 0 deletions
44
eZ/Bundle/EzPublishLegacyBundle/Controller/PreviewController.php
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,44 @@ | ||
<?php | ||
/** | ||
* File containing the PreviewController class. | ||
* | ||
* @copyright Copyright (C) 1999-2014 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\EzPublishLegacyBundle\Controller; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Content; | ||
use eZ\Publish\API\Repository\Values\Content\Location; | ||
use eZ\Publish\Core\MVC\ConfigResolverInterface; | ||
use eZ\Publish\Core\MVC\Symfony\Controller\Content\PreviewController as BasePreviewController; | ||
use eZ\Publish\Core\MVC\Symfony\SiteAccess; | ||
|
||
class PreviewController extends BasePreviewController | ||
{ | ||
/** | ||
* @var \eZ\Publish\Core\MVC\ConfigResolverInterface | ||
*/ | ||
private $configResolver; | ||
|
||
/** | ||
* @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver | ||
*/ | ||
public function setConfigResolver( ConfigResolverInterface $configResolver ) | ||
{ | ||
$this->configResolver = $configResolver; | ||
} | ||
|
||
protected function getForwardRequest( Location $location, Content $content, SiteAccess $previewSiteAccess ) | ||
{ | ||
$request = parent::getForwardRequest( $location, $content, $previewSiteAccess ); | ||
// If the preview siteaccess is configured in legacy_mode, we forward to the LegacyKernelController. | ||
if ( $this->configResolver->getParameter( 'legacy_mode', 'ezsettings', $previewSiteAccess->name ) ) | ||
{ | ||
$request->attributes->set( '_controller', 'ezpublish_legacy.controller:indexAction' ); | ||
} | ||
|
||
return $request; | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
eZ/Bundle/EzPublishLegacyBundle/Tests/Controller/PreviewControllerTest.php
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,68 @@ | ||
<?php | ||
/** | ||
* File containing the PreviewControllerTest class. | ||
* | ||
* @copyright Copyright (C) 1999-2014 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\EzPublishLegacyBundle\Tests\Controller; | ||
|
||
use eZ\Bundle\EzPublishLegacyBundle\Controller\PreviewController; | ||
use eZ\Publish\API\Repository\Values\Content\Content; | ||
use eZ\Publish\API\Repository\Values\Content\Location; | ||
use eZ\Publish\Core\MVC\Symfony\Controller\Tests\Controller\Content\PreviewControllerTest as BasePreviewControllerTest; | ||
use eZ\Publish\Core\MVC\Symfony\SiteAccess; | ||
|
||
class PreviewControllerTest extends BasePreviewControllerTest | ||
{ | ||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $configResolver; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->configResolver = $this->getMock( 'eZ\Publish\Core\MVC\ConfigResolverInterface' ); | ||
} | ||
|
||
/** | ||
* @return \eZ\Bundle\EzPublishLegacyBundle\Controller\PreviewController | ||
*/ | ||
protected function getPreviewController() | ||
{ | ||
$controller = new PreviewController( | ||
$this->contentService, | ||
$this->httpKernel, | ||
$this->previewHelper, | ||
$this->securityContext | ||
); | ||
$controller->setConfigResolver( $this->configResolver ); | ||
|
||
return $controller; | ||
} | ||
|
||
protected function getDuplicatedRequest( Location $location, Content $content, SiteAccess $previewSiteAccess ) | ||
{ | ||
$request = parent::getDuplicatedRequest( | ||
$location, | ||
$content, | ||
$previewSiteAccess | ||
); | ||
$request->attributes->set( '_controller', 'ezpublish_legacy.controller:indexAction' ); | ||
|
||
return $request; | ||
} | ||
|
||
public function testPreview() | ||
{ | ||
$this->configResolver | ||
->expects( $this->any() ) | ||
->method( 'getParameter' ) | ||
->with( 'legacy_mode' ) | ||
->will( $this->returnValue( true ) ); | ||
parent::testPreview(); | ||
} | ||
} |
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