Skip to content

Commit

Permalink
add basic criterion visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
crevillo committed Feb 4, 2019
1 parent f76a092 commit bd4572b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 58 deletions.
16 changes: 0 additions & 16 deletions src/GraphQL/InputMapper/Search/Criterion/ContentTypeIdentifier.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/GraphQL/InputMapper/Search/Criterion/ParentLocationId.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
16 changes: 0 additions & 16 deletions src/GraphQL/InputMapper/Search/Criterion/Text.php

This file was deleted.

22 changes: 14 additions & 8 deletions src/Resources/config/query_input_visitors.yml
Original file line number Diff line number Diff line change
@@ -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'}
Expand All @@ -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'}

0 comments on commit bd4572b

Please sign in to comment.