From 0656536480bf2b2a673eb5f1b2686ad7b7bbd084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Adamczyk?= Date: Mon, 18 Jun 2018 16:14:20 +0200 Subject: [PATCH] EZP-29306: Display notification about missing Language on adding CT instead error 404 --- src/bundle/Controller/ContentTypeController.php | 17 ++++++++++++++++- .../translations/content_type.en.xliff | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/bundle/Controller/ContentTypeController.php b/src/bundle/Controller/ContentTypeController.php index 9d5b5d6c8c..d0389005e3 100644 --- a/src/bundle/Controller/ContentTypeController.php +++ b/src/bundle/Controller/ContentTypeController.php @@ -158,7 +158,22 @@ public function addAction(ContentTypeGroup $group): Response $createStruct->mainLanguageCode = $mainLanguageCode; $createStruct->names = [$mainLanguageCode => 'New Content Type']; - $contentTypeDraft = $this->contentTypeService->createContentType($createStruct, [$group]); + try { + $contentTypeDraft = $this->contentTypeService->createContentType($createStruct, [$group]); + } catch (NotFoundException $e) { + $this->notificationHandler->error( + $this->translator->trans( + /** @Desc("Can not create Content Type. Could not find 'Language' with identifier '%languageCode%'") */ + 'content_type.add.missing_language', + ['%languageCode%' => $mainLanguageCode], + 'content_type' + ) + ); + + return $this->redirectToRoute('ezplatform.content_type_group.view', [ + 'contentTypeGroupId' => $group->id, + ]); + } $form = $this->createUpdateForm($group, $contentTypeDraft); diff --git a/src/bundle/Resources/translations/content_type.en.xliff b/src/bundle/Resources/translations/content_type.en.xliff index 7280cf7153..74b6e8105d 100644 --- a/src/bundle/Resources/translations/content_type.en.xliff +++ b/src/bundle/Resources/translations/content_type.en.xliff @@ -11,6 +11,11 @@ Edit key: content_type.action.edit + + Can not create Content Type. Could not find 'Language' with identifier '%languageCode%' + Can not create Content Type. Could not find 'Language' with identifier '%languageCode%' + key: content_type.add.missing_language + Creating a new Content Type Creating a new Content Type