Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8534: Dropped ContentService::loadRelations usage #72

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,6 @@ parameters:
count: 1
path: src/lib/Resolver/ContentResolver.php

-
message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\ContentResolver\\:\\:findContentRelations\\(\\) should return array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> but returns iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\.$#"
count: 1
path: src/lib/Resolver/ContentResolver.php

-
message: "#^Method Ibexa\\\\GraphQL\\\\Resolver\\\\ContentResolver\\:\\:findContentReverseRelations\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/bundle/Resources/config/services/resolvers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 9 additions & 11 deletions src/lib/Resolver/ContentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading