-
Notifications
You must be signed in to change notification settings - Fork 1
/
Operators.php
61 lines (53 loc) · 2.01 KB
/
Operators.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php declare(strict_types = 1);
namespace LastDragon_ru\LaraASP\GraphQL\SortBy;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
use LastDragon_ru\LaraASP\GraphQL\Builder\Operators as BuilderOperators;
use LastDragon_ru\LaraASP\GraphQL\PackageConfig;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Contracts\Scope;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Definitions\SortByOperatorChildDirective;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Definitions\SortByOperatorFieldDirective;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Definitions\SortByOperatorNullsFirstDirective;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Definitions\SortByOperatorNullsLastDirective;
use LastDragon_ru\LaraASP\GraphQL\SortBy\Directives\Directive;
use LastDragon_ru\LaraASP\GraphQL\Utils\AstManipulator;
use Override;
use function array_merge;
class Operators extends BuilderOperators {
private const Prefix = Directive::Name.'Operators';
public const Extra = self::Prefix.'Extra';
public const Object = self::Prefix.'Object';
public const Disabled = self::Prefix.'Disabled';
/**
* @inheritDoc
*/
protected array $default = [
self::Extra => [
SortByOperatorFieldDirective::class,
SortByOperatorNullsFirstDirective::class,
SortByOperatorNullsLastDirective::class,
],
self::Object => [
SortByOperatorChildDirective::class,
],
];
public function __construct(
ContainerResolver $container,
protected readonly PackageConfig $config,
) {
parent::__construct($container, $this->config->getInstance()->sortBy->operators);
}
#[Override]
public function getScope(): string {
return Scope::class;
}
/**
* @inheritDoc
*/
#[Override]
protected function getDisabledOperators(AstManipulator $manipulator): array {
return array_merge(
parent::getDisabledOperators($manipulator),
$this->getTypeOperators($manipulator, self::Disabled),
);
}
}