Skip to content

Commit

Permalink
#110425 - Mettre à jour et installer le bundle NovaeZEditHelpBundle
Browse files Browse the repository at this point in the history
Fix use eZ\Publish\ in FetchDocumentation.php
  • Loading branch information
RemyNovactive committed Oct 10, 2023
1 parent daf7956 commit 3af92df
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions components/EditHelpBundle/bundle/Services/FetchDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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),
]
),
]
Expand All @@ -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),
]
),
]
Expand Down

0 comments on commit 3af92df

Please sign in to comment.