From 12d052530cb4ea4f1c192198ba1e107714982407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Wed, 3 Oct 2018 11:17:47 +0200 Subject: [PATCH 1/2] Do not render layout when rendering selection and relation items (#2205) --- .../Resources/views/content_fields.html.twig | 6 +++--- .../Resources/views/fielddefinition_settings.html.twig | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig index c471d8de620..8944618dbe8 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig @@ -266,7 +266,7 @@ @@ -331,7 +331,7 @@ {% if parameters.showInfo is defined and not parameters.showInfo %} {% set showInfo = false %} {% endif %} - + {% set draggable = defaultDraggable %} {% if parameters.draggable is defined and not parameters.draggable %} {% set draggable = 'false' %} @@ -436,7 +436,7 @@ {% spaceless %} {% if not ez_is_field_empty( content, field ) and parameters.available %}
- {{ render( controller( "ez_content:viewAction", {'contentId': field.value.destinationContentId, 'viewType': 'text_linked', 'noLayout': 1} ) ) }} + {{ render( controller( "ez_content:viewAction", {'contentId': field.value.destinationContentId, 'viewType': 'text_linked', 'layout': false} ) ) }}
{% endif %} {% endspaceless %} diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/views/fielddefinition_settings.html.twig b/eZ/Bundle/EzPublishCoreBundle/Resources/views/fielddefinition_settings.html.twig index 5fad8f1bfe0..b9b2eb258ad 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/views/fielddefinition_settings.html.twig +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/views/fielddefinition_settings.html.twig @@ -338,7 +338,7 @@
Selection root:
{% if rootLocationId %} - {{ render( controller( "ez_content:viewAction", {'locationId': rootLocationId, 'viewType': 'line'} ), {'strategy': 'esi'}) }} + {{ render( controller( "ez_content:viewAction", {'locationId': rootLocationId, 'viewType': 'line', 'layout': false} ), {'strategy': 'esi'}) }} {% else %} No defined root {% endif %} From f5fae0a9cc2473f6f3cab77a844d4fb6e5742bbf Mon Sep 17 00:00:00 2001 From: Douglas Hammond Date: Wed, 3 Oct 2018 18:37:38 +0200 Subject: [PATCH 2/2] EZP-29510: allow last version to be removed if draft (#2414) Closes #2414. --- eZ/Publish/API/Repository/ContentService.php | 2 +- eZ/Publish/API/Repository/Tests/ContentServiceTest.php | 10 ++++++---- eZ/Publish/Core/Repository/ContentService.php | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/eZ/Publish/API/Repository/ContentService.php b/eZ/Publish/API/Repository/ContentService.php index 19907870e45..3b2fd5724f6 100644 --- a/eZ/Publish/API/Repository/ContentService.php +++ b/eZ/Publish/API/Repository/ContentService.php @@ -308,7 +308,7 @@ public function publishVersion(VersionInfo $versionInfo); * Removes the given version. * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in - * published state or is a last version of the Content + * published state or is a last version of Content in non draft state * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version * * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo diff --git a/eZ/Publish/API/Repository/Tests/ContentServiceTest.php b/eZ/Publish/API/Repository/Tests/ContentServiceTest.php index 1e117aef169..66b490fbe0a 100644 --- a/eZ/Publish/API/Repository/Tests/ContentServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/ContentServiceTest.php @@ -3082,12 +3082,12 @@ public function testDeleteVersionThrowsBadStateExceptionOnPublishedVersion() * Test for the deleteVersion() method. * * @see \eZ\Publish\API\Repository\ContentService::deleteVersion() - * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException + * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContent * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersion */ - public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() + public function testDeleteVersionWorksIfOnlyVersionIsDraft() { $repository = $this->getRepository(); @@ -3096,9 +3096,11 @@ public function testDeleteVersionThrowsBadStateExceptionOnLastVersion() /* BEGIN: Use Case */ $draft = $this->createContentDraftVersion1(); - // This call will fail with a "BadStateException", because the Content - // version is the last version of the Content. $contentService->deleteVersion($draft->getVersionInfo()); + + // This call will fail with a "NotFound", because we allow to delete content if remaining version is draft. + // Can normally only happen if there where always only a draft to begin with, simplifies UI edit API usage. + $contentService->loadContent($draft->id); /* END: Use Case */ } diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php index bb3f4c3d1c5..8a022e8ee39 100644 --- a/eZ/Publish/Core/Repository/ContentService.php +++ b/eZ/Publish/Core/Repository/ContentService.php @@ -1584,7 +1584,7 @@ protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicat * Removes the given version. * * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in - * published state or is the last version of the Content + * published state or is a last version of Content in non draft state * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version * * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo @@ -1612,7 +1612,7 @@ public function deleteVersion(APIVersionInfo $versionInfo) 2 ); - if (count($versionList) === 1) { + if (count($versionList) === 1 && !$versionInfo->isDraft()) { throw new BadStateException( '$versionInfo', 'Version is the last version of the Content and can not be removed'