From b8170e52c626689b3390c2cdfacf9bf9845c1a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Thu, 28 Jan 2021 14:09:29 +0100 Subject: [PATCH 1/3] EZP-32308: Passed mandatory Location into LocationLimitation --- .../ChoiceList/Loader/ContentEditTranslationChoiceLoader.php | 2 +- src/lib/Form/Type/Content/Translation/TranslationAddType.php | 2 +- src/lib/Tab/LocationView/TranslationsTab.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php index deaa37dd4a..09954f6134 100644 --- a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php +++ b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php @@ -77,7 +77,7 @@ function (Language $language) { 'content', 'edit', $this->contentInfo, - [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build()], + [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), $this->contentInfo->getMainLocation()], [Limitation::LANGUAGE] ); diff --git a/src/lib/Form/Type/Content/Translation/TranslationAddType.php b/src/lib/Form/Type/Content/Translation/TranslationAddType.php index e8fd231f4d..fb316d29b6 100644 --- a/src/lib/Form/Type/Content/Translation/TranslationAddType.php +++ b/src/lib/Form/Type/Content/Translation/TranslationAddType.php @@ -197,7 +197,7 @@ public function addLanguageFields(FormInterface $form, array $contentLanguages, 'content', 'edit', $contentInfo, - [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build()], + [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), $contentInfo->getMainLocation()], [Limitation::LANGUAGE] ); diff --git a/src/lib/Tab/LocationView/TranslationsTab.php b/src/lib/Tab/LocationView/TranslationsTab.php index 3c36e8b235..730e7dfbad 100644 --- a/src/lib/Tab/LocationView/TranslationsTab.php +++ b/src/lib/Tab/LocationView/TranslationsTab.php @@ -132,7 +132,7 @@ public function getTemplateParameters(array $contextParameters = []): array 'content', 'edit', $location->getContentInfo(), - [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build()] + [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), $location] ); $viewParameters = [ From b8f4b575b2c77e65b64c26c529899370622f9490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Tue, 2 Feb 2021 16:49:44 +0100 Subject: [PATCH 2/3] EZP-32308: Used locationService instead of non existing proxy object methods for fetching location --- src/bundle/Controller/ContentViewController.php | 3 ++- .../Loader/ContentEditTranslationChoiceLoader.php | 13 +++++++++++-- .../Type/Content/Translation/TranslationAddType.php | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/bundle/Controller/ContentViewController.php b/src/bundle/Controller/ContentViewController.php index 257b0716f4..368c298d8f 100644 --- a/src/bundle/Controller/ContentViewController.php +++ b/src/bundle/Controller/ContentViewController.php @@ -371,7 +371,8 @@ private function createContentEditForm( $this->permissionResolver, $contentInfo, $this->lookupLimitationsTransformer, - $languageCodes + $languageCodes, + $this->locationService ), ] ); diff --git a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php index 09954f6134..c2ca650ca0 100644 --- a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php +++ b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php @@ -9,6 +9,7 @@ namespace EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader; use eZ\Publish\API\Repository\LanguageService; +use eZ\Publish\API\Repository\LocationService; use eZ\Publish\API\Repository\PermissionResolver; use eZ\Publish\API\Repository\Values\Content\ContentInfo; use eZ\Publish\API\Repository\Values\Content\Language; @@ -33,6 +34,9 @@ class ContentEditTranslationChoiceLoader extends BaseChoiceLoader /** @var \EzSystems\EzPlatformAdminUi\Permission\LookupLimitationsTransformer */ private $lookupLimitationsTransformer; + /** @var \eZ\Publish\API\Repository\LocationService */ + private $locationService; + /** * @param \eZ\Publish\API\Repository\LanguageService $languageService * @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver @@ -45,13 +49,15 @@ public function __construct( PermissionResolver $permissionResolver, ?ContentInfo $contentInfo, LookupLimitationsTransformer $lookupLimitationsTransformer, - array $languageCodes + array $languageCodes, + LocationService $locationService ) { $this->languageService = $languageService; $this->permissionResolver = $permissionResolver; $this->contentInfo = $contentInfo; $this->languageCodes = $languageCodes; $this->lookupLimitationsTransformer = $lookupLimitationsTransformer; + $this->locationService = $locationService; } /** @@ -77,7 +83,10 @@ function (Language $language) { 'content', 'edit', $this->contentInfo, - [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), $this->contentInfo->getMainLocation()], + [ + (new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), + $this->locationService->loadLocation($this->contentInfo->mainLocationId) + ], [Limitation::LANGUAGE] ); diff --git a/src/lib/Form/Type/Content/Translation/TranslationAddType.php b/src/lib/Form/Type/Content/Translation/TranslationAddType.php index fb316d29b6..1358c75c7a 100644 --- a/src/lib/Form/Type/Content/Translation/TranslationAddType.php +++ b/src/lib/Form/Type/Content/Translation/TranslationAddType.php @@ -197,7 +197,10 @@ public function addLanguageFields(FormInterface $form, array $contentLanguages, 'content', 'edit', $contentInfo, - [(new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), $contentInfo->getMainLocation()], + [ + (new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), + $this->locationService->loadLocation($contentInfo->mainLocationId) + ], [Limitation::LANGUAGE] ); From 8f760dbc4cdb970e1f6c43a37f88a616bebc31a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Wed, 3 Feb 2021 10:04:22 +0100 Subject: [PATCH 3/3] EZP-32308: Fixed trailing commas --- .../ChoiceList/Loader/ContentEditTranslationChoiceLoader.php | 2 +- src/lib/Form/Type/Content/Translation/TranslationAddType.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php index c2ca650ca0..a21a7b93b4 100644 --- a/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php +++ b/src/lib/Form/Type/ChoiceList/Loader/ContentEditTranslationChoiceLoader.php @@ -85,7 +85,7 @@ function (Language $language) { $this->contentInfo, [ (new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), - $this->locationService->loadLocation($this->contentInfo->mainLocationId) + $this->locationService->loadLocation($this->contentInfo->mainLocationId), ], [Limitation::LANGUAGE] ); diff --git a/src/lib/Form/Type/Content/Translation/TranslationAddType.php b/src/lib/Form/Type/Content/Translation/TranslationAddType.php index 1358c75c7a..0ef6ab1170 100644 --- a/src/lib/Form/Type/Content/Translation/TranslationAddType.php +++ b/src/lib/Form/Type/Content/Translation/TranslationAddType.php @@ -199,7 +199,7 @@ public function addLanguageFields(FormInterface $form, array $contentLanguages, $contentInfo, [ (new Target\Builder\VersionBuilder())->translateToAnyLanguageOf($languagesCodes)->build(), - $this->locationService->loadLocation($contentInfo->mainLocationId) + $this->locationService->loadLocation($contentInfo->mainLocationId), ], [Limitation::LANGUAGE] );