From 3af92dfaf468081cde9888709a79d9cc8cedc63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20LIMOUZIN?= Date: Tue, 10 Oct 2023 10:08:23 +0200 Subject: [PATCH] =?UTF-8?q?#110425=20-=20Mettre=20=C3=A0=20jour=20et=20ins?= =?UTF-8?q?taller=20le=20bundle=20NovaeZEditHelpBundle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix use eZ\Publish\ in FetchDocumentation.php --- .../bundle/Services/FetchDocumentation.php | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/components/EditHelpBundle/bundle/Services/FetchDocumentation.php b/components/EditHelpBundle/bundle/Services/FetchDocumentation.php index 0b4c69d4a..4947968c0 100644 --- a/components/EditHelpBundle/bundle/Services/FetchDocumentation.php +++ b/components/EditHelpBundle/bundle/Services/FetchDocumentation.php @@ -14,15 +14,14 @@ namespace Novactive\Bundle\NovaeZEditHelpBundle\Services; -use eZ\Publish\API\Repository\Repository; -use eZ\Publish\API\Repository\Values\Content\Content; -use eZ\Publish\API\Repository\Values\Content\LocationQuery; -use eZ\Publish\API\Repository\Values\Content\Query; -use eZ\Publish\API\Repository\Values\Content\Query\Criterion; -use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Field; -use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd; -use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId; -use eZ\Publish\Core\Repository\Values\ContentType\ContentType; +use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; +use Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery; +use Ibexa\Contracts\Core\Repository\Values\Content\Query; +use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; +use Ibexa\Core\Repository\SiteAccessAware\Repository; class FetchDocumentation { @@ -36,10 +35,10 @@ public function getByContentType(ContentType $contentType): ?Content { $query = new Query( [ - 'filter' => new LogicalAnd( + 'filter' => new Query\Criterion\LogicalAnd( [ - new Criterion\ContentTypeIdentifier([self::TOOLTIP_CONTENT_TYPE]), - new Field('identifier', '=', $contentType->identifier), + new Query\Criterion\ContentTypeIdentifier([self::TOOLTIP_CONTENT_TYPE]), + new Query\Criterion\Field('identifier', '=', $contentType->identifier), ] ), ] @@ -49,19 +48,29 @@ public function getByContentType(ContentType $contentType): ?Content $searchResult = $searchService->findContent($query); // Content is found if ($searchResult->totalCount > 0) { - return $searchResult->searchHits[0]->valueObject; + $hit = $searchResult->searchHits[0]; + $valueObject = $hit->valueObject; + if ($valueObject instanceof Content) { + return $valueObject; + } } return null; } + /** + * @param int $locationId + * @return SearchHit[] de Content. + * @throws InvalidArgumentException + * @throws InvalidCriterionArgumentException + */ public function getChildrenByLocationId(int $locationId): array { $query = new LocationQuery( [ - 'filter' => new LogicalAnd( + 'filter' => new Query\Criterion\LogicalAnd( [ - new ParentLocationId($locationId), + new Query\Criterion\ParentLocationId($locationId), ] ), ]