@param NodeBuilder $filterDefinition

@throws \InvalidArgumentException
@throws \RuntimeException
553384
protected function appendFilterDefinition(NodeBuilder $filterDefinition): void
    {
        $fieldDefinition = $filterDefinition
            ->scalarNode('provider')->isRequired()->end()
            ->integerNode('results_per_page')->defaultValue(15)->end()
            ->arrayNode('sortable')
                ->prototype('scalar')->end()
            ->end()
            ->arrayNode('default_sort')
                ->prototype('scalar')->defaultValue([])->end()
            ->end()
            ->variableNode('options')
                ->defaultValue([])
                ->validate()
                    ->ifTrue(function ($value) {
                        return !\is_array($value) && null !== $value;
                    })
                    ->thenInvalid('"options" configuration must be an array or left empty')
                ->end()
            ->end()
            ->arrayNode('filters')
                ->prototype('array')
                    ->children();

        $this->appendFieldDefinition($fieldDefinition);

        $fieldDefinition->end()
                ->end()
            ->end();
    }
639645
public function getFilter(GetFilterEvent $event): void
    {
        $filter = $this->buildSharingFilter($event);
        $filter = $this->buildOwnerFilter($event, $filter);

        $event->setFilterConstraint($filter);
    }
1361124
private function dispatchBuild(CriterionDefinition $definition)
    {
        switch ($definition->name) {
            case 'content_type':
                return $this->buildContentTypeIdentifier($definition);
            case 'depth':
                return $this->buildDepth($definition);
            case 'field':
                return $this->buildField($definition);
            case 'main':
                return $this->buildIsMainLocation($definition);
            case 'not':
                return $this->buildLogicalNot($definition);
            case 'parent_location_id':
                return $this->buildParentLocationId($definition);
            case 'priority':
                return $this->buildPriority($definition);
            case 'publication_date':
                return $this->buildDateMetadataCreated($definition);
            case 'section':
                return $this->buildSection($definition);
            case 'state':
                return $this->buildObjectState($definition);
            case 'subtree':
                return $this->buildSubtree($definition);
            case 'visible':
                return $this->buildVisibility($definition);
        }

        throw new InvalidArgumentException(
            "Criterion named '{$definition->name}' is not handled"
        );
    }
901388
protected function addFilterToQueryBuilder(array $filter, QueryBuilder $queryBuilder)
    {
        $objectManager    = $this->getObjectManager();
        $entityClassAlias = $this->getEntityClassAlias();
        $classMetaData    = $objectManager->getClassMetadata($this->getEntityClass());
        $assocMappings    = $classMetaData->getAssociationMappings();

        $andExpressions = array();
        $paramCounter   = 0;

        foreach ($filter as $property => $value) {
            if (empty($value)) {
                continue;
            }

            if (!isset($assocMappings[$property])) {
                throw new \InvalidArgumentException('Unkown association "' . $property . '"');
            }
            $paramCounter++;
            $queryBuilder->andWhere($queryBuilder->expr()->eq($entityClassAlias . '.' .$property, '?' . $paramCounter));
            $queryBuilder->setParameter($paramCounter, $value);

        }

        return $paramCounter;
    }
255612
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();

        // Check if the event has a nodeTranslation, if not this method can be skipped
        if (!$request->attributes->has('_nodeTranslation')) {
            return;
        }

        $nodeTranslation = $request->attributes->get('_nodeTranslation');
        if (!($nodeTranslation instanceof NodeTranslation)) {
            throw new \Exception('Invalid _nodeTranslation value found in request attributes');
        }
        $entity = $nodeTranslation->getRef($this->em);

        // If the entity is an instance of the SlugActionInterface, change the controller
        if ($entity instanceof SlugActionInterface) {
            $request->attributes->set('_entity', $entity);

            // Do security check by firing an event that gets handled by the SlugSecurityListener
            $securityEvent = new SlugSecurityEvent();
            $securityEvent
                ->setNode($nodeTranslation->getNode())
                ->setEntity($entity)
                ->setRequest($request)
                ->setNodeTranslation($nodeTranslation);

            $this->eventDispatcher->dispatch(Events::SLUG_SECURITY, $securityEvent);

            // Set the right controller
            $request->attributes->set('_controller', $entity->getControllerAction());
            $event->setController($this->resolver->getController($request));
        }
    }
563761
protected function filter(string $filterName)
    {
        if (! $this->validateManipulation($filterName, 'filter')) {
            throw InvalidManipulation::invalidParameter(
                'filter',
                $filterName,
                $this->getValidManipulationOptions('filter')
            );
        }

        return $this->addManipulation('filter', $filterName);
    }
625037
public function setDefinition(ExecutableDefinitionInterface $definition): ContextBuilder
    {
        $this->definition = $definition;

        $type = null;
        if ($definition instanceof NodeAwareDefinitionInterface && $definition->getNode()) {
            $type = $definition->getNode();
        }

        if (!$type) {
            $type = $definition->getType();
        }

        if ($this->endpoint->hasType($type)
            && ($nodeDefinition = $this->endpoint->getType($type))
            && ($nodeDefinition instanceof ObjectDefinition || $nodeDefinition instanceof InterfaceDefinition)) {
            $this->node = $nodeDefinition;
        }

        return $this;
    }
1188273
public static function createFilter(Endpoint $endpoint, FieldDefinition $field): Filter
    {
        $filter = new Filter();
        $filter->name = $filter->field = $field->getName();

        switch (TypeUtil::normalize($field->getType())) {
            case Types::STRING:
                $filter->resolver = StringFilter::class;
                $filter->type = StringComparisonExpression::class;
                if ($field->isList()) {
                    $filter->resolver = ArrayFilter::class;
                    $filter->type = ArrayComparisonExpression::class;
                }
                break;
            case Types::BOOLEAN:
                $filter->resolver = BooleanFilter::class;
                $filter->type = Types::BOOLEAN;
                break;
            case Types::DATE:
                $filter->resolver = DateFilter::class;
                $filter->type = DateComparisonExpression::class;
                break;
            case Types::DATETIME:
                $filter->resolver = DateFilter::class;
                $filter->type = DateTimeComparisonExpression::class;
                break;
            case Types::INT:
                $filter->resolver = NumberFilter::class;
                $filter->type = IntegerComparisonExpression::class;
                break;
            case Types::FLOAT:
                $filter->resolver = NumberFilter::class;
                $filter->type = FloatComparisonExpression::class;
                break;
        }

        //enums
        if (!$filter->resolver
            && $endpoint->hasType($field->getType())
            && $endpoint->getType($field->getType()) instanceof EnumDefinition) {
            /** @var EnumDefinition $relatedNode */
            $relatedNode = $endpoint->getType($field->getType());
            //enum registered using enum definition
            $enumName = $relatedNode->getName();
            foreach ($relatedNode->getValues() as $value) {
                $enumValues[] = $value->getName();
            }
            $filter = self::createEnumFilter($endpoint, $field, $enumName, $enumValues);
            $filter->field = $field->getName();
        }

        //enum registered as internal GraphQL type
        if (!$filter->resolver && TypeRegistry::has($field->getType())
            && ($enumType = TypeRegistry::get($field->getType()))
            && $enumType instanceof EnumType) {
            $enumName = $enumType->name;
            foreach ($enumType->getValues() as $value) {
                $enumValues[] = $value->name;
            }
            $filter = self::createEnumFilter($endpoint, $field, $enumName, $enumValues);
        }

        //relations and enums
        if (!$filter->resolver
            && $endpoint->hasType($field->getType())
            && $endpoint->getType($field->getType()) instanceof ClassAwareDefinitionInterface) {
            /** @var ClassAwareDefinitionInterface $relatedNode */
            $relatedNode = $endpoint->getType($field->getType());
            $relatedEntity = $relatedNode->getClass();
            try {
                $ref = new \ReflectionClass($relatedEntity);
                if ($ref->implementsInterface(NodeInterface::class)) {
                    $filter->resolver = NodeFilter::class;
                    $filter->type = NodeComparisonExpression::class;
                }
            } catch (\ReflectionException $exception) {
                //ignore invalid class or empty
            }
        }

        return $filter;
    }
1044714
private static function determineFilterAndOr(array $filter, QueryBuilder $queryBuilder)
    {
        if (!\in_array($filter['operation'], ['AND', 'OR'])) {
            return null;
        }

        static::filterAndOr($filter, $queryBuilder);

        return '';
    }
884972
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition(static::MANAGER_DEFINITION)) {
            return;
        }

        $manager = $container->getDefinition(static::MANAGER_DEFINITION);
        $services = $container->findTaggedServiceIds(static::SERVICE_TAG);

        foreach ($services as $id => $attributes) {
            if (! isset($attributes[0]['key']) || empty($attributes[0]['key'])) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Service "%s" must define the "key" attribute on "thelia.asset.filter" tag.',
                        $id
                    )
                );
            }

            $class = $container->getDefinition($id)->getClass();

            if (! is_subclass_of($class, '\Assetic\Filter\FilterInterface')) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Service "%s" should implement the \Assetic\Filter\FilterInterface interface',
                        $id
                    )
                );
            }

            $manager->addMethodCall(
                'registerAssetFilter',
                [ $attributes[0]['key'], new Reference($id) ]
            );
        }
    }
61621
protected function applySpecification(QueryBuilder $queryBuilder, $specification = null, $alias = null)
    {
        if (null === $specification) {
            return;
        }

        if (!$specification instanceof QueryModifier && !$specification instanceof Filter) {
            throw new \InvalidArgumentException(sprintf(
                'Expected argument of type "%s" or "%s", "%s" given.',
                QueryModifier::class,
                Filter::class,
                is_object($specification) ? get_class($specification) : gettype($specification)
            ));
        }

        if ($specification instanceof QueryModifier) {
            $specification->modify($queryBuilder, $alias ?: $this->getAlias());
        }

        if ($specification instanceof Filter
            && $filter = (string) $specification->getFilter($queryBuilder, $alias ?: $this->getAlias())
        ) {
            $queryBuilder->andWhere($filter);
        }
    }
1094795
private void initDefinition(NodeData parent) throws RepositoryException, ConstraintViolationException
   {
      if (this.isRoot())
      {
         // root - no parent
         this.definition =
            new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, true,
               new InternalQName[]{Constants.NT_BASE}, null, false);
         return;
      }

      if (parent == null)
      {
         parent = (NodeData)dataManager.getItemData(getParentIdentifier());
      }

      this.definition =
         session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
            nodeData().getPrimaryTypeName(), parent.getPrimaryTypeName(), parent.getMixinTypeNames());

      if (definition == null)
      {
         throw new ConstraintViolationException("Node definition not found for " + getPath());
      }
   }
338132
public function addFilterHandler($filterName, $filterHandlerName, $priority = 50)
    {
        $this->addHandler(self::FILTER, $filterName, $filterHandlerName, $priority);
    }
646683
protected function buildFilterActions(FormBuilderInterface $builder): void
    {
        $visibleFilterCount = 0;
        foreach ($this->getQueryHandler()->getConfiguration()->getFilters() as $filter) {
            $filter->getOption('hidden') ?: $visibleFilterCount++;
        }
        if ($visibleFilterCount > 0) {
            $this->buildResetAction($builder);
            $this->buildSubmitAction($builder);
        }
    }
190169
private function addFilters(ExecutableDefinitionInterface $definition, string $targetType, Endpoint $endpoint): void
    {
        $filterName = ucfirst($definition->getName()).'Filter';
        if ($endpoint->hasType($filterName)) {
            $filters = $endpoint->getType($filterName);
        } else {
            $filters = new InputObjectDefinition();
            $filters->setName($filterName);
            $endpoint->add($filters);

            $object = $endpoint->getType($targetType);
            if ($object instanceof FieldsAwareDefinitionInterface) {
                foreach ($object->getFields() as $field) {
                    if ('id' === $field->getName()
                        || !$field->getOriginName()
                        || \ReflectionProperty::class !== $field->getOriginType()) {
                        continue;
                    }

                    $filter = new FieldDefinition();
                    $filter->setName($field->getName());
                    $type = $field->getType();
                    if ($endpoint->hasType($type)) {
                        $typeDefinition = $endpoint->getType($type);
                        if (!$typeDefinition instanceof EnumDefinition) {
                            $type = 'ID';
                        }
                        $filter->setList(true);
                    }

                    // fields using custom object as type
                    // are not available for filters
                    if (TypeRegistry::getTypeMapp()) {
                        if (isset(TypeRegistry::getTypeMapp()[$type])) {
                            $class = TypeRegistry::getTypeMapp()[$type];
                            $ref = new \ReflectionClass($class);
                            if ($ref->isSubclassOf(ObjectType::class)) {
                                continue;
                            }
                        }
                    }

                    $filter->setType($type);
                    $filters->addField($filter);
                }
            }
        }

        if (!$filters->getFields()) {
            return;
        }

        $search = new ArgumentDefinition();
        $search->setName('filters');
        $search->setType($filters->getName());
        $deprecateMessage = \is_string($this->bcConfig['filters']) ? $this->bcConfig['filters'] : '**DEPRECATED** use `where` instead to filter the list.';
        $search->setDescription($deprecateMessage);
        $search->setNonNull(false);
        $definition->addArgument($search);
    }
431076
public function addPolicyDefinition(PolicyDefinition $definition)
  {
    // Do not include excluded dependencies
    if (!in_array($definition->getName(), $this->excludedPolicies)) {
      $this->policies[$definition->getName()] = $definition;
    }
    return $this;
  }
158263
public static function addOptions(InputDefinition $definition, array $fields, $description)
    {
        foreach ($fields as $field => $type) {
            $mode = 'array' === $type
                ? InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
                : InputOption::VALUE_REQUIRED;

            if (!$definition->hasOption($field) && !$definition->hasArgument($field)) {
                $definition->addOption(new InputOption($field, null, $mode, sprintf($description, $field, $type)));
            }
        }
    }