|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Modelarium\Laravel\Directives; |
|
4
|
|
|
|
|
5
|
|
|
use Modelarium\Exception\DirectiveException; |
|
6
|
|
|
use Modelarium\Exception\Exception; |
|
7
|
|
|
use Modelarium\Laravel\Targets\MigrationGenerator; |
|
8
|
|
|
use Modelarium\Laravel\Targets\ModelGenerator; |
|
9
|
|
|
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface; |
|
10
|
|
|
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface; |
|
11
|
|
|
use Modelarium\Laravel\Targets\MigrationCodeFragment; |
|
12
|
|
|
|
|
13
|
|
|
class MigrationRememberTokenDirective implements MigrationDirectiveInterface, ModelDirectiveInterface |
|
14
|
3 |
|
{ |
|
15
|
|
|
public static function processMigrationTypeDirective( |
|
16
|
|
|
MigrationGenerator $generator, |
|
17
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
18
|
3 |
|
): void { |
|
19
|
3 |
|
$generator->createCode[] = '$table->rememberToken();'; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public static function processMigrationFieldDirective( |
|
23
|
|
|
MigrationGenerator $generator, |
|
24
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
25
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive, |
|
26
|
|
|
MigrationCodeFragment $code |
|
27
|
|
|
): void { |
|
28
|
|
|
throw new DirectiveException("Directive not supported here"); |
|
29
|
|
|
} |
|
30
|
1 |
|
|
|
31
|
|
|
public static function processMigrationRelationshipDirective( |
|
32
|
|
|
MigrationGenerator $generator, |
|
33
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
34
|
1 |
|
\GraphQL\Language\AST\DirectiveNode $directive, |
|
35
|
1 |
|
MigrationCodeFragment $code |
|
36
|
|
|
): void { |
|
37
|
|
|
throw new DirectiveException("Directive not supported here"); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public static function processModelTypeDirective( |
|
41
|
|
|
ModelGenerator $generator, |
|
42
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
43
|
|
|
): void { |
|
44
|
|
|
$generator->hidden[] = 'remember_token'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public static function processModelFieldDirective( |
|
48
|
|
|
ModelGenerator $generator, |
|
49
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
50
|
|
|
\Formularium\Field $fieldFormularium, |
|
51
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
52
|
|
|
): void { |
|
53
|
|
|
// nothing |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public static function processModelRelationshipDirective( |
|
57
|
|
|
ModelGenerator $generator, |
|
58
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
|
59
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
|
60
|
|
|
): string { |
|
61
|
|
|
// nothing |
|
62
|
|
|
return ''; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|