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: Replaced Abstract Criterion with CriterionInterface #1403

Merged
merged 3 commits into from
Dec 11, 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
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12226,11 +12226,6 @@ parameters:
count: 1
path: tests/lib/Pagination/Pagerfanta/TrashItemAdapterTest.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\:\\:\\$query \\(Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\CriterionInterface&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
count: 2
path: tests/lib/Pagination/Pagerfanta/TrashItemAdapterTest.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\:\\:\\$sortClauses \\(array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\SortClause\\>\\) does not accept Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\SortClause&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\.$#"
count: 2
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function uploadImageAction(Request $request): Response
$content = $this->imageAssetMapper->createAsset(
$file->getClientOriginalName(),
new ImageValue([
'path' => $file->getRealPath(),
'inputUri' => $file->getRealPath(),
'fileSize' => $file->getSize(),
'fileName' => $file->getClientOriginalName(),
'alternativeText' => $file->getClientOriginalName(),
Expand Down
3 changes: 1 addition & 2 deletions src/bundle/Controller/Content/ContentTreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\User\Limitation;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Rest\Message;
Expand Down Expand Up @@ -79,7 +78,7 @@ public function loadChildrenAction(
int $parentLocationId,
int $limit,
int $offset,
?Criterion $filter
?Query\CriterionInterface $filter
): Node {
$location = $this->locationService->loadLocation($parentLocationId);
$loadSubtreeRequestNode = new LoadSubtreeRequestNode($parentLocationId, $limit, $offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace Ibexa\Bundle\AdminUi\ControllerArgumentResolver;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
Expand All @@ -34,12 +34,16 @@ public function __construct(

public function supports(Request $request, ArgumentMetadata $argument): bool
{
return Criterion::class === $argument->getType()
if ($argument->getType() === null) {
return false;
}

return is_a($argument->getType(), CriterionInterface::class, true)
&& 'filter' === $argument->getName();
}

/**
* @return iterable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion|null>
* @return iterable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface|null>
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
Expand All @@ -56,7 +60,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
}

/**
* @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion>
* @return array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface>
*/
private function processFilterQueryCriteria(Request $request): array
{
Expand Down
3 changes: 2 additions & 1 deletion src/lib/REST/Input/Parser/ContentTree/LoadSubtreeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Ibexa\AdminUi\REST\Value\ContentTree\LoadSubtreeRequest as LoadSubtreeRequestValue;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
use Ibexa\Rest\Server\Input\Parser\Criterion as CriterionParser;
Expand Down Expand Up @@ -45,7 +46,7 @@ public function parse(array $data, ParsingDispatcher $parsingDispatcher): LoadSu
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException
*/
private function processCriteriaArray(array $criteriaArray, ParsingDispatcher $parsingDispatcher): ?Criterion
private function processCriteriaArray(array $criteriaArray, ParsingDispatcher $parsingDispatcher): ?CriterionInterface
{
if (count($criteriaArray) === 0) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/REST/Value/ContentTree/LoadSubtreeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

namespace Ibexa\AdminUi\REST\Value\ContentTree;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Rest\Value as RestValue;

class LoadSubtreeRequest extends RestValue
{
/** @var \Ibexa\AdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode[] */
public array $nodes;

public ?Criterion $filter;
public ?CriterionInterface $filter;

/**
* @param array $nodes
*/
public function __construct(array $nodes = [], ?Criterion $filter = null)
public function __construct(array $nodes = [], ?CriterionInterface $filter = null)
{
$this->nodes = $nodes;
$this->filter = $filter;
Expand Down
15 changes: 8 additions & 7 deletions src/lib/UI/Module/ContentTree/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\TermAggregationResult;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
Expand Down Expand Up @@ -96,7 +97,7 @@ public function createNode(
int $depth = 0,
?string $sortClause = null,
string $sortOrder = Query::SORT_ASC,
?Criterion $requestFilter = null
?Query\CriterionInterface $requestFilter = null
): Node {
$uninitializedContentInfoList = [];
$containerLocations = [];
Expand Down Expand Up @@ -150,7 +151,7 @@ private function findSubitems(
int $offset = 0,
?string $sortClause = null,
string $sortOrder = Query::SORT_ASC,
?Criterion $requestFilter = null
?CriterionInterface $requestFilter = null
): SearchResult {
$searchQuery = $this->getSearchQuery($parentLocation->getId(), $requestFilter);

Expand All @@ -164,7 +165,7 @@ private function findSubitems(
/**
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $parentLocation
*/
private function getSearchQuery(int $parentLocationId, ?Criterion $requestFilter = null): LocationQuery
private function getSearchQuery(int $parentLocationId, ?CriterionInterface $requestFilter = null): LocationQuery
{
$searchQuery = new LocationQuery();
$searchQuery->filter = new Criterion\ParentLocationId($parentLocationId);
Expand Down Expand Up @@ -206,7 +207,7 @@ private function findChild(int $locationId, LoadSubtreeRequestNode $loadSubtreeR
/**
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
private function countSubitems(int $parentLocationId, ?Criterion $requestFilter = null): int
private function countSubitems(int $parentLocationId, ?CriterionInterface $requestFilter = null): int
{
$searchQuery = $this->getSearchQuery($parentLocationId, $requestFilter);

Expand All @@ -223,7 +224,7 @@ private function countSubitems(int $parentLocationId, ?Criterion $requestFilter
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException
*/
private function countAggregatedSubitems(array $containerLocations, ?Criterion $requestFilter): array
private function countAggregatedSubitems(array $containerLocations, ?CriterionInterface $requestFilter): array
{
if (empty($containerLocations)) {
return [];
Expand Down Expand Up @@ -338,7 +339,7 @@ private function buildNode(
?string $sortClause = null,
string $sortOrder = Query::SORT_ASC,
array $bookmarkLocations = [],
?Criterion $requestFilter = null
?CriterionInterface $requestFilter = null
): Node {
$contentInfo = $location->getContentInfo();
$contentId = $location->getContentId();
Expand Down Expand Up @@ -443,7 +444,7 @@ private function supplyTranslatedContentName(Node $node, array $versionInfoById)
private function supplyChildrenCount(
Node $node,
?array $aggregationResult = null,
?Criterion $requestFilter = null
?CriterionInterface $requestFilter = null
): void {
if ($node->isContainer) {
if ($aggregationResult !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function provideDataForTestSupports(): iterable
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
public function testResolve(
Criterion $expected,
CriterionInterface $expected,
Request $request,
Traversable $expectedCriteria,
array $criteriaToProcess = []
Expand All @@ -133,9 +134,9 @@ public function testResolve(

/**
* @return iterable<array{
* \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion,
* \Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface,
* \Symfony\Component\HttpFoundation\Request,
* \Traversable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion>,
* \Traversable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface>,
* 3?: array<string, string>,
* }>
*
Expand Down
Loading