diff --git a/src/GraphQL/InputMapper/Search/Criterion/ContentTypeIdentifier.php b/src/GraphQL/InputMapper/Search/Criterion/ContentTypeIdentifier.php deleted file mode 100644 index 462465e0..00000000 --- a/src/GraphQL/InputMapper/Search/Criterion/ContentTypeIdentifier.php +++ /dev/null @@ -1,16 +0,0 @@ -addCriterion(new Query\Criterion\ContentTypeIdentifier($value)); - } -} diff --git a/src/GraphQL/InputMapper/Search/Criterion/ParentLocationId.php b/src/GraphQL/InputMapper/Search/Criterion/ParentLocationId.php deleted file mode 100644 index 995abe19..00000000 --- a/src/GraphQL/InputMapper/Search/Criterion/ParentLocationId.php +++ /dev/null @@ -1,15 +0,0 @@ -addCriterion(new Query\Criterion\ParentLocationId($value)); - } -} diff --git a/src/GraphQL/InputMapper/Search/Criterion/ContentTypeId.php b/src/GraphQL/InputMapper/Search/Criterion/Standard.php similarity index 55% rename from src/GraphQL/InputMapper/Search/Criterion/ContentTypeId.php rename to src/GraphQL/InputMapper/Search/Criterion/Standard.php index 05f4d327..79d4fa29 100644 --- a/src/GraphQL/InputMapper/Search/Criterion/ContentTypeId.php +++ b/src/GraphQL/InputMapper/Search/Criterion/Standard.php @@ -2,14 +2,20 @@ namespace EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion; -use eZ\Publish\API\Repository\Values\Content\Query; use EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\QueryBuilder; use EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\QueryInputVisitor; -class ContentTypeId implements QueryInputVisitor +class Standard implements QueryInputVisitor { + private $criterionClass; + + public function __construct($criterionClass) + { + $this->criterionClass = $criterionClass; + } + public function visit(QueryBuilder $queryBuilder, $value): void { - $queryBuilder->addCriterion(new Query\Criterion\ContentTypeId($value)); + $queryBuilder->addCriterion(new {$this->criterionClass}($value)); } } diff --git a/src/GraphQL/InputMapper/Search/Criterion/Text.php b/src/GraphQL/InputMapper/Search/Criterion/Text.php deleted file mode 100644 index c6c60203..00000000 --- a/src/GraphQL/InputMapper/Search/Criterion/Text.php +++ /dev/null @@ -1,16 +0,0 @@ -addCriterion(new Query\Criterion\FullText($value)); - } -} diff --git a/src/Resources/config/query_input_visitors.yml b/src/Resources/config/query_input_visitors.yml index 7da1a774..7244b606 100644 --- a/src/Resources/config/query_input_visitors.yml +++ b/src/Resources/config/query_input_visitors.yml @@ -1,16 +1,26 @@ services: - EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\ContentTypeIdentifier: - tags: - - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'ContentTypeIdentifier'} - EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\ContentTypeId: + class: EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\Standard + arguments: + $criterionClass: 'eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId' tags: - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'ContentTypeId'} EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\Text: + class: EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\Standard + arguments: + $criterionClass: 'eZ\Publish\API\Repository\Values\Content\Query\Criterion\Fulltext' tags: - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'Text'} + EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\ParentLocationId: + class: EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\Standard + arguments: + $criterionClass: 'eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId' + tags: + - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'ParentLocationId'} + + EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\Created: tags: - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'Created'} @@ -23,10 +33,6 @@ services: tags: - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'Field'} - EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\Criterion\ParentLocationId: - tags: - - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'ParentLocationId'} - EzSystems\EzPlatformGraphQL\GraphQL\InputMapper\Search\SortBy: tags: - {name: 'ezplatform_graphql.query_input_visitor', inputKey: 'SortBy'}