Skip to content

Commit 738ebf8

Browse files
author
Bertrand Dunogier
committed
Added permissions check of group types with graphql/content
1 parent 48b76a0 commit 738ebf8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

DomainContent/SchemaWorker/ContentType/AddDomainContentToDomainGroup.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function work(array &$schema, array $args)
2828
'type' => sprintf("[%s]", $this->getContentName($contentType)),
2929
// @todo Improve description to mention that it is a collection ?
3030
'description' => isset($descriptions['eng-GB']) ? $descriptions['eng-GB'] : 'No description available',
31+
'public' => $this->getPublicValue($contentType),
3132
'resolve' => sprintf(
3233
'@=resolver("DomainContentItemsByTypeIdentifier", ["%s", args])',
3334
$contentType->identifier
@@ -47,6 +48,7 @@ public function work(array &$schema, array $args)
4748
'type' => $this->getContentName($contentType),
4849
'description' => isset($descriptions['eng-GB']) ? $descriptions['eng-GB'] : 'No description available',
4950
'resolve' => sprintf('@=resolver("DomainContentItem", [args, "%s"])', $contentType->identifier),
51+
'public' => $this->getPublicValue($contentType),
5052
'args' => [
5153
// @todo How do we constraint this so that it only takes an id of an item of that type ?
5254
// same approach than GlobalId ? (<type>-<id>)
@@ -140,4 +142,16 @@ private function isFieldDefined(ContentTypeGroup $contentTypeGroup, ContentType
140142
[$this->getContentCollectionField($contentType)]
141143
);
142144
}
145+
146+
/**
147+
* @param $contentType
148+
* @return string
149+
*/
150+
protected function getPublicValue($contentType): string
151+
{
152+
return sprintf(
153+
'@=service("ezplatform_graphql.can_user").viewContentOfType("%s")',
154+
$contentType->identifier
155+
);
156+
}
143157
}

0 commit comments

Comments
 (0)