1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Modelarium\Laravel\Directives; |
4
|
|
|
|
5
|
|
|
use Modelarium\Exception\Exception; |
6
|
|
|
use Modelarium\Laravel\Targets\MigrationGenerator; |
7
|
|
|
use Modelarium\Laravel\Targets\ModelGenerator; |
8
|
|
|
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface; |
9
|
|
|
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface; |
10
|
|
|
|
11
|
|
|
class MigrationSpatialIndexDirective implements MigrationDirectiveInterface, ModelDirectiveInterface |
12
|
|
|
{ |
13
|
1 |
|
public static function processMigrationTypeDirective( |
14
|
|
|
MigrationGenerator $generator, |
15
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
16
|
|
|
): void { |
17
|
|
|
/** @phpstan-ignore-next-line */ |
18
|
1 |
|
$generator->createCode[] = '$table->spatialIndex("' . $directive->arguments[0]->value->value .'");'; |
|
|
|
|
19
|
1 |
|
} |
20
|
|
|
|
21
|
|
|
public static function processMigrationFieldDirective( |
22
|
|
|
MigrationGenerator $generator, |
23
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
24
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
25
|
|
|
): void { |
26
|
|
|
// nothing |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public static function processModelTypeDirective( |
30
|
|
|
ModelGenerator $generator, |
31
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
32
|
|
|
): void { |
33
|
|
|
throw new Exception("Primary index is not implemented yet"); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public static function processModelFieldDirective( |
37
|
|
|
ModelGenerator $generator, |
38
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
39
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
40
|
|
|
): void { |
41
|
|
|
// nothing |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function processModelRelationshipDirective( |
45
|
|
|
ModelGenerator $generator, |
46
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
47
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
48
|
|
|
): string { |
49
|
|
|
// nothing |
50
|
|
|
return ''; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|