Skip to content

Commit

Permalink
Merge pull request #513 from mikadamczyk/EZP-29306
Browse files Browse the repository at this point in the history
EZP-29306: Display notification about missing Language on adding CT i…
  • Loading branch information
Łukasz Serwatka authored Jun 19, 2018
2 parents a991575 + d27f57f commit 16c105f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/bundle/Controller/ContentTypeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("Cannot 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);

Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/content_type.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<target state="new">Edit</target>
<note>key: content_type.action.edit</note>
</trans-unit>
<trans-unit id="0a08ba6425acc6e52b75ebbe0b77d90df5cb81a1" resname="content_type.add.missing_language">
<source>Cannot create Content Type. Could not find 'Language' with identifier '%languageCode%'</source>
<target state="new">Cannot create Content Type. Could not find 'Language' with identifier '%languageCode%'</target>
<note>key: content_type.add.missing_language</note>
</trans-unit>
<trans-unit id="0aef83746d192c9b507ecabebe250aeb684cc210" resname="content_type.breadcrumb.create">
<source>Creating a new Content Type</source>
<target state="new">Creating a new Content Type</target>
Expand Down

0 comments on commit 16c105f

Please sign in to comment.