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