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 generateGraphQLItems() |
21
|
|
|
{ |
22
|
|
|
if (false === ($this->isSkip('queries') or $this->isSkip('graphql_query'))) { |
23
|
|
|
$queryGenerator = new GraphQLQueryGenerator($this->commandData); |
24
|
|
|
$queryGenerator->generate(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
if (false === ($this->isSkip('types') or $this->isSkip('graphql_types'))) { |
28
|
|
|
$typeGenerator = new GraphQLTypeGenerator($this->commandData); |
29
|
|
|
$typeGenerator->generate(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if (false === ($this->isSkip('mutations') or $this->isSkip('graphql_mutations'))) { |
33
|
|
|
$mutationGenerator = new GraphQLMutationGenerator($this->commandData); |
34
|
|
|
$mutationGenerator->generate(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (false === ($this->isSkip('inputs') or $this->isSkip('graphql_inputs'))) { |
38
|
|
|
$mutationGenerator = new GraphQLInputGenerator($this->commandData); |
39
|
|
|
$mutationGenerator->generate(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if ((false === ($this->isSkip('subscription') or $this->isSkip('graphql_subscription'))) and config('pwweb.artomator.options.subscription')) { |
43
|
|
|
$subscriptionGenerator = new GraphQLSubscriptionGenerator($this->commandData); |
44
|
|
|
$subscriptionGenerator->generate(); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function generateScaffoldItems() |
49
|
|
|
{ |
50
|
|
|
if (false === $this->isSkip('requests') and false === $this->isSkip('scaffold_requests')) { |
51
|
|
|
$requestGenerator = new RequestGenerator($this->commandData); |
52
|
|
|
$requestGenerator->generate(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if (false === $this->isSkip('controllers') and false === $this->isSkip('scaffold_controller')) { |
56
|
|
|
$controllerGenerator = new ControllerGenerator($this->commandData); |
57
|
|
|
$controllerGenerator->generate(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (false === $this->isSkip('views')) { |
61
|
|
|
$viewGenerator = new ViewGenerator($this->commandData); |
62
|
|
|
$viewGenerator->generate(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (false === $this->isSkip('routes') and false === $this->isSkip('scaffold_routes')) { |
66
|
|
|
$routeGenerator = new RoutesGenerator($this->commandData); |
67
|
|
|
$routeGenerator->generate(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (false === $this->isSkip('menu') and $this->commandData->config->getAddOn('menu.enabled')) { |
71
|
|
|
$menuGenerator = new MenuGenerator($this->commandData); |
72
|
|
|
$menuGenerator->generate(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the console command options. |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function getOptions() |
82
|
|
|
{ |
83
|
|
|
return array_merge(parent::getOptions(), [ |
84
|
|
|
['gqlName', null, InputOption::VALUE_REQUIRED, 'Override the name used in the GraphQL schema file'], |
85
|
|
|
]); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|