PHP Class ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter

Abstract class with helpers for easing the implementation of a filter.
Author: Kévin Dunglas ([email protected])
Author: Théo FIDRY ([email protected])
Inheritance: implements ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\FilterInterface
Datei anzeigen Open project: api-platform/core Class Usage Examples

Protected Properties

Property Type Description
$logger
$managerRegistry
$properties
$requestStack

Public Methods

Method Description
__construct ( Doctrine\Common\Persistence\ManagerRegistry $managerRegistry, Symfony\Component\HttpFoundation\RequestStack $requestStack, Psr\Log\LoggerInterface $logger = null, array $properties = null )
apply ( Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null )

Protected Methods

Method Description
addJoinOnce ( Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $association ) : string Adds a join to the queryBuilder if none exists.
addJoinsForNestedProperty ( string $property, string $rootAlias, Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator ) : array Adds the necessary joins for a nested property.
extractProperties ( Request $request ) : array Extracts properties to filter from the request.
filterProperty ( string $property, mixed $value, Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null ) Passes a property through the filter.
getClassMetadata ( string $resourceClass ) : Doctrine\Common\Persistence\Mapping\ClassMetadata Gets class metadata for the given resource.
getNestedMetadata ( string $resourceClass, array $associations ) : Doctrine\Common\Persistence\Mapping\ClassMetadata Gets nested class metadata for the given resource.
isPropertyEnabled ( string $property ) : boolean Determines whether the given property is enabled.
isPropertyMapped ( string $property, string $resourceClass, boolean $allowAssociation = false ) : boolean Determines whether the given property is mapped.
isPropertyNested ( string $property ) : boolean Determines whether the given property is nested.
splitPropertyParts ( string $property ) : array Splits the given property into parts.

Private Methods

Method Description
getExistingJoin ( Doctrine\ORM\QueryBuilder $queryBuilder, string $alias, string $association ) : Doctrine\ORM\Query\Expr\Join | null Get the existing join from queryBuilder DQL parts.

Method Details

__construct() public method

public __construct ( Doctrine\Common\Persistence\ManagerRegistry $managerRegistry, Symfony\Component\HttpFoundation\RequestStack $requestStack, Psr\Log\LoggerInterface $logger = null, array $properties = null )
$managerRegistry Doctrine\Common\Persistence\ManagerRegistry
$requestStack Symfony\Component\HttpFoundation\RequestStack
$logger Psr\Log\LoggerInterface
$properties array

addJoinOnce() protected method

Adds a join to the queryBuilder if none exists.
protected addJoinOnce ( Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $association ) : string
$queryBuilder Doctrine\ORM\QueryBuilder
$queryNameGenerator ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface
$alias string
$association string the association field
return string the new association alias

addJoinsForNestedProperty() protected method

Adds the necessary joins for a nested property.
protected addJoinsForNestedProperty ( string $property, string $rootAlias, Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator ) : array
$property string
$rootAlias string
$queryBuilder Doctrine\ORM\QueryBuilder
$queryNameGenerator ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface
return array An array where the first element is the join $alias of the leaf entity, the second element is the $field name the third element is the $associations array

apply() public method

public apply ( Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null )
$queryBuilder Doctrine\ORM\QueryBuilder
$queryNameGenerator ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface
$resourceClass string
$operationName string

extractProperties() protected method

Extracts properties to filter from the request.
protected extractProperties ( Request $request ) : array
$request Symfony\Component\HttpFoundation\Request
return array

filterProperty() abstract protected method

Passes a property through the filter.
abstract protected filterProperty ( string $property, mixed $value, Doctrine\ORM\QueryBuilder $queryBuilder, ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null )
$property string
$value mixed
$queryBuilder Doctrine\ORM\QueryBuilder
$queryNameGenerator ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface
$resourceClass string
$operationName string

getClassMetadata() protected method

Gets class metadata for the given resource.
protected getClassMetadata ( string $resourceClass ) : Doctrine\Common\Persistence\Mapping\ClassMetadata
$resourceClass string
return Doctrine\Common\Persistence\Mapping\ClassMetadata

getNestedMetadata() protected method

Gets nested class metadata for the given resource.
protected getNestedMetadata ( string $resourceClass, array $associations ) : Doctrine\Common\Persistence\Mapping\ClassMetadata
$resourceClass string
$associations array
return Doctrine\Common\Persistence\Mapping\ClassMetadata

isPropertyEnabled() protected method

Determines whether the given property is enabled.
protected isPropertyEnabled ( string $property ) : boolean
$property string
return boolean

isPropertyMapped() protected method

Determines whether the given property is mapped.
protected isPropertyMapped ( string $property, string $resourceClass, boolean $allowAssociation = false ) : boolean
$property string
$resourceClass string
$allowAssociation boolean
return boolean

isPropertyNested() protected method

Determines whether the given property is nested.
protected isPropertyNested ( string $property ) : boolean
$property string
return boolean

splitPropertyParts() protected method

Returns an array with the following keys: - associations: array of associations according to nesting order - field: string holding the actual field (leaf node)
protected splitPropertyParts ( string $property ) : array
$property string
return array

Property Details

$logger protected_oe property

protected $logger

$managerRegistry protected_oe property

protected $managerRegistry

$properties protected_oe property

protected $properties

$requestStack protected_oe property

protected $requestStack