From 89301fcb5a0f936d387974cfc043f66ee7742f07 Mon Sep 17 00:00:00 2001 From: Kamil Madejski Date: Mon, 4 Mar 2019 13:37:21 +0100 Subject: [PATCH] EZP-29979: As a developer I would like to use getLocation method on ContentCreateSuccessView and ContentEditSuccessView (#270) * EZP-29979: As a developer I would like to use getLocation method on ContentCreateSuccessView and ContentEditSuccessView * Removed null from setLocation * Update lib/Content/View/ContentCreateSuccessView.php Co-Authored-By: kmadejski * Update lib/Content/View/ContentEditSuccessView.php Co-Authored-By: kmadejski * Recovered possiblity to pass null to setLocation method --- .../View/Builder/ContentCreateViewBuilder.php | 5 +++- .../View/Builder/ContentEditViewBuilder.php | 5 +++- lib/Content/View/ContentCreateSuccessView.php | 23 ++++++++++++++++++- lib/Content/View/ContentEditSuccessView.php | 23 ++++++++++++++++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/Content/View/Builder/ContentCreateViewBuilder.php b/lib/Content/View/Builder/ContentCreateViewBuilder.php index beac63012..48669cb68 100644 --- a/lib/Content/View/Builder/ContentCreateViewBuilder.php +++ b/lib/Content/View/Builder/ContentCreateViewBuilder.php @@ -103,7 +103,10 @@ public function buildView(array $parameters) ); if ($response = $this->contentActionDispatcher->getResponse()) { - return new ContentCreateSuccessView($response); + $view = new ContentCreateSuccessView($response); + $view->setLocation($location); + + return $view; } } diff --git a/lib/Content/View/Builder/ContentEditViewBuilder.php b/lib/Content/View/Builder/ContentEditViewBuilder.php index 82a4182cd..2e863de69 100644 --- a/lib/Content/View/Builder/ContentEditViewBuilder.php +++ b/lib/Content/View/Builder/ContentEditViewBuilder.php @@ -122,7 +122,10 @@ public function buildView(array $parameters) ); if ($response = $this->contentActionDispatcher->getResponse()) { - return new ContentEditSuccessView($response); + $view = new ContentEditSuccessView($response); + $view->setLocation($location); + + return $view; } } diff --git a/lib/Content/View/ContentCreateSuccessView.php b/lib/Content/View/ContentCreateSuccessView.php index 478242b5c..73966ae7a 100644 --- a/lib/Content/View/ContentCreateSuccessView.php +++ b/lib/Content/View/ContentCreateSuccessView.php @@ -7,12 +7,17 @@ namespace EzSystems\RepositoryForms\Content\View; +use eZ\Publish\API\Repository\Values\Content\Location; use eZ\Publish\Core\MVC\Symfony\View\BaseView; +use eZ\Publish\Core\MVC\Symfony\View\LocationValueView; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; -class ContentCreateSuccessView extends BaseView +class ContentCreateSuccessView extends BaseView implements LocationValueView { + /** @var \eZ\Publish\API\Repository\Values\Content\Location|null */ + private $location; + /** * @param \Symfony\Component\HttpFoundation\Response $response * @@ -25,4 +30,20 @@ public function __construct(Response $response) $this->setResponse($response); $this->setControllerReference(new ControllerReference('ez_content_edit:createWithoutDraftSuccessAction')); } + + /** + * @param \eZ\Publish\API\Repository\Values\Content\Location|null $location + */ + public function setLocation(?Location $location): void + { + $this->location = $location; + } + + /** + * @return \eZ\Publish\API\Repository\Values\Content\Location|null + */ + public function getLocation(): ?Location + { + return $this->location; + } } diff --git a/lib/Content/View/ContentEditSuccessView.php b/lib/Content/View/ContentEditSuccessView.php index 528d7d5f3..8e5146d2b 100644 --- a/lib/Content/View/ContentEditSuccessView.php +++ b/lib/Content/View/ContentEditSuccessView.php @@ -7,12 +7,17 @@ namespace EzSystems\RepositoryForms\Content\View; +use eZ\Publish\API\Repository\Values\Content\Location; use eZ\Publish\Core\MVC\Symfony\View\BaseView; +use eZ\Publish\Core\MVC\Symfony\View\LocationValueView; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; -class ContentEditSuccessView extends BaseView +class ContentEditSuccessView extends BaseView implements LocationValueView { + /** @var \eZ\Publish\API\Repository\Values\Content\Location|null */ + private $location; + /** * @param \Symfony\Component\HttpFoundation\Response $response * @@ -25,4 +30,20 @@ public function __construct(Response $response) $this->setResponse($response); $this->setControllerReference(new ControllerReference('ez_content_edit:editVersionDraftSuccessAction')); } + + /** + * @param \eZ\Publish\API\Repository\Values\Content\Location|null $location + */ + public function setLocation(?Location $location): void + { + $this->location = $location; + } + + /** + * @return \eZ\Publish\API\Repository\Values\Content\Location|null + */ + public function getLocation(): ?Location + { + return $this->location; + } }