|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Modelarium\Laravel\Directives; |
|
4
|
|
|
|
|
5
|
|
|
use Modelarium\Laravel\Targets\ModelGenerator; |
|
6
|
|
|
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface; |
|
7
|
|
|
|
|
8
|
|
|
class RenderableDirective implements ModelDirectiveInterface |
|
9
|
|
|
{ |
|
10
|
|
|
public static function processModelTypeDirective( |
|
11
|
|
|
ModelGenerator $generator, |
|
12
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
13
|
|
|
): void { |
|
14
|
|
|
foreach ($directive->arguments as $arg) { |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \GraphQL\Language\AST\ArgumentNode $arg |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
$argName = $arg->name->value; |
|
20
|
|
|
$argValue = $arg->value->value; /** @phpstan-ignore-line */ |
|
|
|
|
|
|
21
|
|
|
$generator->fModel->appendRenderable($argName, $argValue); |
|
22
|
|
|
} |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public static function processModelFieldDirective( |
|
26
|
|
|
ModelGenerator $generator, |
|
27
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
28
|
|
|
\Formularium\Field $fieldFormularium, |
|
29
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
30
|
|
|
): void { |
|
31
|
|
|
// handled by FormulariumUtils::getFieldFromDirectives() |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public static function processModelRelationshipDirective( |
|
35
|
|
|
ModelGenerator $generator, |
|
36
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
37
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive, |
|
38
|
|
|
\Formularium\Datatype $datatype = null |
|
39
|
|
|
): ?\Formularium\Datatype { |
|
40
|
|
|
return null; |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|