From 3c775249d00d873b23e3bfff05719f0d8c8d8e94 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 27 May 2020 16:12:16 +0200 Subject: [PATCH] EZP-30925: Added `LanguageLimitation` functionality to `Translations` tab (#1383) --- src/lib/UI/Value/ValueFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/UI/Value/ValueFactory.php b/src/lib/UI/Value/ValueFactory.php index f6b36e415b..6d86485038 100644 --- a/src/lib/UI/Value/ValueFactory.php +++ b/src/lib/UI/Value/ValueFactory.php @@ -31,6 +31,7 @@ use eZ\Publish\API\Repository\Values\User\Policy; use eZ\Publish\API\Repository\Values\User\RoleAssignment; use eZ\Publish\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface; +use eZ\Publish\SPI\Limitation\Target\Builder\VersionBuilder; use EzSystems\EzPlatformAdminUi\Specification\UserExists; use EzSystems\EzPlatformAdminUi\UI\Dataset\DatasetFactory; use EzSystems\EzPlatformAdminUi\UI\Service\PathService; @@ -141,8 +142,10 @@ public function createVersionInfo(VersionInfo $versionInfo): UIValue\Content\Ver */ public function createLanguage(Language $language, VersionInfo $versionInfo): UIValue\Content\Language { + $target = (new VersionBuilder())->translateToAnyLanguageOf([$language->languageCode])->build(); + return new UIValue\Content\Language($language, [ - 'userCanRemove' => $this->permissionResolver->canUser('content', 'remove', $versionInfo), + 'userCanRemove' => $this->permissionResolver->canUser('content', 'remove', $versionInfo, [$target]), 'userCanEdit' => $this->permissionResolver->canUser('content', 'edit', $versionInfo), 'main' => $language->languageCode === $versionInfo->getContentInfo()->mainLanguageCode, ]);