Skip to content

Commit b75dd35

Browse files
authored
Remove exception existing translation keys (#994)
* Update TranslationRepository.php * Update TranslationRepositoryInterface.php * remove exception phpdoc * remove inheritdoc * remove HttpResponseCodes::CONFLICT * remove not needed phpdoc * Apply php-cs-fixer changes --------- Co-authored-by: Corepex <16717695+Corepex@users.noreply.github.com>
1 parent 242c4fe commit b75dd35

5 files changed

Lines changed: 1 addition & 20 deletions

File tree

src/Translation/Controller/CreateController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public function __construct(
6464
description: 'translation_create_success_response'
6565
)]
6666
#[DefaultResponses([
67-
HttpResponseCodes::CONFLICT,
6867
HttpResponseCodes::NOT_FOUND,
6968
HttpResponseCodes::UNAUTHORIZED,
7069
])]

src/Translation/Repository/TranslationRepository.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
namespace Pimcore\Bundle\StudioBackendBundle\Translation\Repository;
1818

1919
use Pimcore\Bundle\StaticResolverBundle\Lib\Tools\AdminResolverInterface;
20-
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementExistsException;
2120
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidLocaleException;
2221
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
2322
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\CreateTranslationData;
@@ -26,7 +25,6 @@
2625
use Pimcore\Model\Translation;
2726
use Pimcore\Model\Translation\Listing;
2827
use function in_array;
29-
use function sprintf;
3028

3129
/**
3230
* @internal
@@ -53,19 +51,14 @@ public function getAllTranslations(string $locale): array
5351
return $list->getTranslations();
5452
}
5553

56-
/**
57-
* {@inheritdoc}
58-
*/
5954
public function createTranslations(array $translationData): void
6055
{
6156
$languages = $this->adminResolver->getLanguages();
6257

6358
/** @var CreateTranslationData $translation */
6459
foreach ($translationData as $translation) {
6560
if ($this->getTranslationByKey($translation->getKey()) !== null) {
66-
throw new ElementExistsException(
67-
sprintf("Translation with key '%s' already exists", $translation->getKey()),
68-
);
61+
continue;
6962
}
7063

7164
$this->createTranslationEntry($translation->getKey(), $translation->getType(), $languages);

src/Translation/Repository/TranslationRepositoryInterface.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
namespace Pimcore\Bundle\StudioBackendBundle\Translation\Repository;
1818

19-
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementExistsException;
2019
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidLocaleException;
2120
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\TranslationData;
2221
use Pimcore\Model\Translation;
@@ -33,9 +32,6 @@ interface TranslationRepositoryInterface
3332
*/
3433
public function getAllTranslations(string $locale): array;
3534

36-
/**
37-
* @throws ElementExistsException
38-
*/
3935
public function createTranslations(array $translationData): void;
4036

4137
/**

src/Translation/Service/TranslatorService.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public function __construct(
4242
$this->translatorBag = $this->getTranslatorBag();
4343
}
4444

45-
/**
46-
* {@inheritdoc}
47-
*/
4845
public function createTranslations(CreateTranslation $translation): void
4946
{
5047
$this->translationRepository->createTranslations($translation->getTranslationData());

src/Translation/Service/TranslatorServiceInterface.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
namespace Pimcore\Bundle\StudioBackendBundle\Translation\Service;
1818

19-
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementExistsException;
2019
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidLocaleException;
2120
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\CreateTranslation;
2221
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\Translation;
@@ -29,9 +28,6 @@ interface TranslatorServiceInterface
2928
{
3029
public const string DOMAIN = 'studio';
3130

32-
/**
33-
* @throws ElementExistsException
34-
*/
3531
public function createTranslations(CreateTranslation $translation): void;
3632

3733
/**

0 commit comments

Comments
 (0)