Skip to content

Commit

Permalink
- adapted to use Api Platform Core 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
metaclass-nl committed Oct 11, 2022
1 parent bb1986e commit 2cd5524
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 11 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
Filter logic for API Platform
=============================
UNDER DEVELOPMENT
status:
- only tested with Api Platform core 2.7 (metadata_backward_compatibility_layer: false)

Combines API Platform ORM Filters with AND, OR and NOT according to client request.
- supports nested logic (like parentheses in SQL)
- supports multiple criteria for the same property
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/AddFakeLeftJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function apply(
string $resourceClass,
Operation $operation = null,
array $context = []
) {
): void {
// $queryBuilder->leftJoin(self::$FAKEJOIN, null);
$rootAliases = $queryBuilder->getRootAliases();
$join = new Join(
Expand Down
6 changes: 2 additions & 4 deletions src/Filter/FilterLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Metaclass\FilterBundle\Filter;

use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter;
use ApiPlatform\Doctrine\Orm\Filter\FilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
Expand All @@ -24,7 +23,7 @@
*
* Copyright (c) MetaClass, Groningen, 2021-2022. MIT License
*/
class FilterLogic extends AbstractFilter
class FilterLogic implements FilterInterface
{
/** @var ContainerInterface */
private $filterLocator;
Expand All @@ -43,9 +42,8 @@ class FilterLogic extends AbstractFilter
* but also changes the behavior of ExistsFilter =false.
* {@inheritdoc}
*/
public function __construct(ContainerInterface $filterLocator, ManagerRegistry $managerRegistry, LoggerInterface $logger = null, array $properties = null, NameConverterInterface $nameConverter = null, string $classExp='//', $innerJoinsLeft=false)
public function __construct(ContainerInterface $filterLocator, protected ManagerRegistry $managerRegistry, protected ?LoggerInterface $logger = null, protected ?array $properties = null, protected ?NameConverterInterface $nameConverter = null, string $classExp='//', $innerJoinsLeft=false)
{
parent::__construct($managerRegistry, $logger, $properties, $nameConverter);
$this->filterLocator = $filterLocator;
$this->classExp = $classExp;
$this->innerJoinsLeft = $innerJoinsLeft;
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/RemoveFakeLeftJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function apply(
string $resourceClass,
Operation $operation = null,
array $context = []
) {
): void {
self::removeItFrom($queryBuilder);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/FilterToTestAssumptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getDescription(string $resourceClass): array

}

public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, Operation $operation = null, array $context = [])
public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, Operation $operation = null, array $context = []): void
{
if (isset($context['filters']['setWhere'])) {
$field = key($context['filters']['setWhere']);
Expand Down

0 comments on commit 2cd5524

Please sign in to comment.