From 3752f549f19ff743b9ea226c2459770be9bf87ba Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Fri, 11 Oct 2024 15:46:35 +0200 Subject: [PATCH 1/2] IBX-8534: Dropped ContentService::loadRelations usage --- phpstan-baseline.neon | 10 ---------- src/lib/Resolver/ContentResolver.php | 20 +++++++++----------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dd907d4..95f9006 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -630,11 +630,6 @@ parameters: count: 1 path: src/lib/Resolver/ContentResolver.php - - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\ContentResolver\\:\\:findContentRelations\\(\\) should return array\\ but returns iterable\\\\.$#" - count: 1 - path: src/lib/Resolver/ContentResolver.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\ContentResolver\\:\\:findContentReverseRelations\\(\\) has no return type specified\\.$#" count: 1 @@ -680,11 +675,6 @@ parameters: count: 1 path: src/lib/Resolver/ContentResolver.php - - - message: "#^Property Ibexa\\\\GraphQL\\\\Resolver\\\\ContentResolver\\:\\:\\$contentTypeService is never read, only written\\.$#" - count: 1 - path: src/lib/Resolver/ContentResolver.php - - message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\ContentThumbnailResolver\\:\\:resolveContentThumbnail\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 diff --git a/src/lib/Resolver/ContentResolver.php b/src/lib/Resolver/ContentResolver.php index 0033b1d..733b1aa 100644 --- a/src/lib/Resolver/ContentResolver.php +++ b/src/lib/Resolver/ContentResolver.php @@ -8,10 +8,11 @@ namespace Ibexa\GraphQL\Resolver; use Ibexa\Contracts\Core\Repository\ContentService; -use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\SearchService; use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Relation; +use Ibexa\Contracts\Core\Repository\Values\Content\RelationList\RelationListItemInterface; use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; @@ -30,16 +31,10 @@ class ContentResolver */ private $searchService; - /** - * @var \Ibexa\Contracts\Core\Repository\ContentTypeService - */ - private $contentTypeService; - - public function __construct(ContentService $contentService, SearchService $searchService, ContentTypeService $contentTypeService) + public function __construct(ContentService $contentService, SearchService $searchService) { $this->contentService = $contentService; $this->searchService = $searchService; - $this->contentTypeService = $contentTypeService; } public function findContentByType($contentTypeId) @@ -63,9 +58,12 @@ static function (SearchHit $searchHit) { */ public function findContentRelations(ContentInfo $contentInfo, $version = null) { - return $this->contentService->loadRelations( - $this->contentService->loadVersionInfo($contentInfo, $version) - ); + return array_filter(array_map( + static fn (RelationListItemInterface $relationListItem): ?Relation => $relationListItem->getRelation(), + $this->contentService->loadRelationList( + $this->contentService->loadVersionInfo($contentInfo, $version) + )->items + )); } public function findContentReverseRelations(ContentInfo $contentInfo) From ac52070559525d60d68b3ff8294b8ebbff530864 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Mon, 14 Oct 2024 10:03:32 +0200 Subject: [PATCH 2/2] Dropped ContentTypeService argument from service definition --- src/bundle/Resources/config/services/resolvers.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bundle/Resources/config/services/resolvers.yaml b/src/bundle/Resources/config/services/resolvers.yaml index 8b55469..3543669 100644 --- a/src/bundle/Resources/config/services/resolvers.yaml +++ b/src/bundle/Resources/config/services/resolvers.yaml @@ -27,7 +27,6 @@ services: arguments: $contentService: '@ibexa.siteaccessaware.service.content' $searchService: '@ibexa.siteaccessaware.service.search' - $contentTypeService: '@ibexa.siteaccessaware.service.content_type' Ibexa\GraphQL\Resolver\DomainContentResolver: tags: