1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PWWEB\Artomator\Commands; |
4
|
|
|
|
5
|
|
|
use InfyOm\Generator\Commands\BaseCommand as Base; |
6
|
|
|
use InfyOm\Generator\Generators\Scaffold\ControllerGenerator; |
7
|
|
|
use InfyOm\Generator\Generators\Scaffold\MenuGenerator; |
8
|
|
|
use InfyOm\Generator\Generators\Scaffold\RequestGenerator; |
9
|
|
|
use InfyOm\Generator\Generators\Scaffold\ViewGenerator; |
10
|
|
|
use PWWEB\Artomator\Generators\GraphQL\GraphQLInputGenerator; |
11
|
|
|
use PWWEB\Artomator\Generators\GraphQL\GraphQLMutationGenerator; |
12
|
|
|
use PWWEB\Artomator\Generators\GraphQL\GraphQLQueryGenerator; |
13
|
|
|
use PWWEB\Artomator\Generators\GraphQL\GraphQLSubscriptionGenerator; |
14
|
|
|
use PWWEB\Artomator\Generators\GraphQL\GraphQLTypeGenerator; |
15
|
|
|
use PWWEB\Artomator\Generators\Scaffold\RoutesGenerator; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
|
18
|
|
|
class BaseCommand extends Base |
19
|
|
|
{ |
20
|
|
|
public function handle() |
21
|
|
|
{ |
22
|
|
|
parent::handle(); |
23
|
|
|
$this->commandData->config->prepareGraphQLNames($this->option('gqlName')); |
24
|
|
|
$this->commandData = $this->commandData->config->loadDynamicGraphQLVariables($this->commandData); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function generateGraphQLItems() |
28
|
|
|
{ |
29
|
|
|
if (false === ($this->isSkip('queries') or $this->isSkip('graphql_query'))) { |
30
|
|
|
$queryGenerator = new GraphQLQueryGenerator($this->commandData); |
31
|
|
|
$queryGenerator->generate(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if (false === ($this->isSkip('types') or $this->isSkip('graphql_types'))) { |
35
|
|
|
$typeGenerator = new GraphQLTypeGenerator($this->commandData); |
36
|
|
|
$typeGenerator->generate(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if (false === ($this->isSkip('mutations') or $this->isSkip('graphql_mutations'))) { |
40
|
|
|
$mutationGenerator = new GraphQLMutationGenerator($this->commandData); |
41
|
|
|
$mutationGenerator->generate(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if (false === ($this->isSkip('inputs') or $this->isSkip('graphql_inputs'))) { |
45
|
|
|
$mutationGenerator = new GraphQLInputGenerator($this->commandData); |
46
|
|
|
$mutationGenerator->generate(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
if ((false === ($this->isSkip('subscription') or $this->isSkip('graphql_subscription'))) and config('pwweb.artomator.options.subscription')) { |
50
|
|
|
$subscriptionGenerator = new GraphQLSubscriptionGenerator($this->commandData); |
51
|
|
|
$subscriptionGenerator->generate(); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function generateScaffoldItems() |
56
|
|
|
{ |
57
|
|
|
if (false === $this->isSkip('requests') and false === $this->isSkip('scaffold_requests')) { |
58
|
|
|
$requestGenerator = new RequestGenerator($this->commandData); |
59
|
|
|
$requestGenerator->generate(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if (false === $this->isSkip('controllers') and false === $this->isSkip('scaffold_controller')) { |
63
|
|
|
$controllerGenerator = new ControllerGenerator($this->commandData); |
64
|
|
|
$controllerGenerator->generate(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if (false === $this->isSkip('views')) { |
68
|
|
|
$viewGenerator = new ViewGenerator($this->commandData); |
69
|
|
|
$viewGenerator->generate(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if (false === $this->isSkip('routes') and false === $this->isSkip('scaffold_routes')) { |
73
|
|
|
$routeGenerator = new RoutesGenerator($this->commandData); |
74
|
|
|
$routeGenerator->generate(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if (false === $this->isSkip('menu') and $this->commandData->config->getAddOn('menu.enabled')) { |
78
|
|
|
$menuGenerator = new MenuGenerator($this->commandData); |
79
|
|
|
$menuGenerator->generate(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Get the console command options. |
85
|
|
|
* |
86
|
|
|
* @return array |
87
|
|
|
*/ |
88
|
|
|
public function getOptions() |
89
|
|
|
{ |
90
|
|
|
return array_merge(parent::getOptions(), [ |
91
|
|
|
['gqlName', null, InputOption::VALUE_REQUIRED, 'Override the name used in the GraphQL schema file'], |
92
|
|
|
]); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|