Skip to content

Commit

Permalink
EZP-28944: ISE 500 when deleting Draft (ezsystems#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
webhdx authored and Łukasz Serwatka committed Mar 16, 2018
1 parent b62494b commit 810d81c
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 8 deletions.
36 changes: 31 additions & 5 deletions bundle/Controller/ContentEditController.php
Expand Up @@ -11,7 +11,9 @@
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\ContentTypeService;
use EzSystems\RepositoryForms\Content\View\ContentCreateDraftView;
use EzSystems\RepositoryForms\Content\View\ContentCreateSuccessView;
use EzSystems\RepositoryForms\Content\View\ContentCreateView;
use EzSystems\RepositoryForms\Content\View\ContentEditSuccessView;
use EzSystems\RepositoryForms\Content\View\ContentEditView;
use EzSystems\RepositoryForms\Data\Content\CreateContentDraftData;
use EzSystems\RepositoryForms\Form\ActionDispatcher\ActionDispatcherInterface;
Expand Down Expand Up @@ -44,9 +46,21 @@ public function __construct(
*
* @param \EzSystems\RepositoryForms\Content\View\ContentCreateView $view
*
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateView|\Symfony\Component\HttpFoundation\Response
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateView
*/
public function createWithoutDraftAction(ContentCreateView $view)
public function createWithoutDraftAction(ContentCreateView $view): ContentCreateView
{
return $view;
}

/**
* @param \EzSystems\RepositoryForms\Content\View\ContentCreateSuccessView $view
*
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateSuccessView
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
*/
public function createWithoutDraftSuccessAction(ContentCreateSuccessView $view): ContentCreateSuccessView
{
return $view;
}
Expand Down Expand Up @@ -113,11 +127,23 @@ public function createContentDraftAction(
/**
* @param \EzSystems\RepositoryForms\Content\View\ContentEditView $view
*
* @return \EzSystems\RepositoryForms\Content\View\ContentEditView|\Symfony\Component\HttpFoundation\Response
* @return \EzSystems\RepositoryForms\Content\View\ContentEditView
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
*/
public function editVersionDraftAction(ContentEditView $view): ContentEditView
{
return $view;
}

/**
* @param \EzSystems\RepositoryForms\Content\View\ContentEditSuccessView $view
*
* @return \EzSystems\RepositoryForms\Content\View\ContentEditSuccessView
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
*/
public function editVersionDraftAction(ContentEditView $view)
public function editVersionDraftSuccessAction(ContentEditSuccessView $view): ContentEditSuccessView
{
return $view;
}
Expand All @@ -132,7 +158,7 @@ public function editVersionDraftAction(ContentEditView $view)
* @param string $language Language code to create the version in (eng-GB, ger-DE, ...))
* @param int|null $locationId
*
* @return \EzSystems\RepositoryForms\Content\View\ContentEditView|\Symfony\Component\HttpFoundation\Response
* @return \Symfony\Component\HttpFoundation\Response
*/
public function editContentDraftAction(
$contentId,
Expand Down
1 change: 1 addition & 0 deletions bundle/Resources/views/http/302_empty_content.html.twig
@@ -0,0 +1 @@
{# do not put anything in here #}
5 changes: 3 additions & 2 deletions lib/Content/View/Builder/ContentCreateViewBuilder.php
Expand Up @@ -16,6 +16,7 @@
use eZ\Publish\Core\MVC\Symfony\View\Builder\ViewBuilder;
use eZ\Publish\Core\MVC\Symfony\View\Configurator;
use eZ\Publish\Core\MVC\Symfony\View\ParametersInjector;
use EzSystems\RepositoryForms\Content\View\ContentCreateSuccessView;
use EzSystems\RepositoryForms\Content\View\ContentCreateView;
use EzSystems\RepositoryForms\Form\ActionDispatcher\ActionDispatcherInterface;

Expand Down Expand Up @@ -63,7 +64,7 @@ public function matches($argument)
/**
* @param array $parameters
*
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateView
* @return \EzSystems\RepositoryForms\Content\View\ContentCreateSuccessView|\EzSystems\RepositoryForms\Content\View\ContentCreateView
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
Expand All @@ -88,7 +89,7 @@ public function buildView(array $parameters)
);

if ($response = $this->contentActionDispatcher->getResponse()) {
$view->setResponse($response);
return new ContentCreateSuccessView($response);
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Content/View/Builder/ContentEditViewBuilder.php
Expand Up @@ -17,6 +17,7 @@
use eZ\Publish\Core\MVC\Symfony\View\Builder\ViewBuilder;
use eZ\Publish\Core\MVC\Symfony\View\Configurator;
use eZ\Publish\Core\MVC\Symfony\View\ParametersInjector;
use EzSystems\RepositoryForms\Content\View\ContentEditSuccessView;
use EzSystems\RepositoryForms\Content\View\ContentEditView;
use EzSystems\RepositoryForms\Form\ActionDispatcher\ActionDispatcherInterface;

Expand Down Expand Up @@ -66,6 +67,7 @@ public function matches($argument)
*
* @return \eZ\Publish\Core\MVC\Symfony\View\ContentView|\eZ\Publish\Core\MVC\Symfony\View\View
*
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
* @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
Expand Down Expand Up @@ -103,7 +105,7 @@ public function buildView(array $parameters)
);

if ($response = $this->contentActionDispatcher->getResponse()) {
$view->setResponse($response);
return new ContentEditSuccessView($response);
}
}

Expand Down
28 changes: 28 additions & 0 deletions lib/Content/View/ContentCreateSuccessView.php
@@ -0,0 +1,28 @@
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\RepositoryForms\Content\View;

use eZ\Publish\Core\MVC\Symfony\View\BaseView;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerReference;

class ContentCreateSuccessView extends BaseView
{
/**
* @param \Symfony\Component\HttpFoundation\Response $response
*
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
*/
public function __construct(Response $response)
{
parent::__construct('@EzSystemsRepositoryForms/http/302_empty_content.html.twig');

$this->setResponse($response);
$this->setControllerReference(new ControllerReference('ez_content_edit:createWithoutDraftSuccessAction'));
}
}
28 changes: 28 additions & 0 deletions lib/Content/View/ContentEditSuccessView.php
@@ -0,0 +1,28 @@
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\RepositoryForms\Content\View;

use eZ\Publish\Core\MVC\Symfony\View\BaseView;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerReference;

class ContentEditSuccessView extends BaseView
{
/**
* @param \Symfony\Component\HttpFoundation\Response $response
*
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
*/
public function __construct(Response $response)
{
parent::__construct('@EzSystemsRepositoryForms/http/302_empty_content.html.twig');

$this->setResponse($response);
$this->setControllerReference(new ControllerReference('ez_content_edit:editVersionDraftSuccessAction'));
}
}

0 comments on commit 810d81c

Please sign in to comment.