Skip to content

Commit

Permalink
IBX-8059: Validate Content Type's Group in the Content Type view acti…
Browse files Browse the repository at this point in the history
…on (#1241)

* IBX-8059: Validate Content Type's Group in the Content Type view action

* IBX-8059: CS

* IBX-8059: Applied review remark
  • Loading branch information
barw4 authored Apr 22, 2024
1 parent 35f04ce commit 2c0de8f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bundle/Controller/ContentTypeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,18 @@ public function viewAction(
ContentType $contentType,
Request $request
): Response {
$contentTypeGroups = $contentType->getContentTypeGroups();
$contentTypeGroupsIds = array_column($contentTypeGroups, 'id');
if (!in_array($group->id, $contentTypeGroupsIds, true)) {
throw $this->createNotFoundException(
sprintf(
'%s content type does not belong to %s content type group.',
$contentType->getName(),
$group->identifier,
),
);
}

$fieldDefinitionsByGroup = [];
foreach ($contentType->fieldDefinitions as $fieldDefinition) {
$fieldDefinitionsByGroup[$fieldDefinition->fieldGroup ?: 'content'][] = $fieldDefinition;
Expand Down

0 comments on commit 2c0de8f

Please sign in to comment.