1 | <?php |
||
7 | class TypeMakeCommand extends GeneratorCommand |
||
8 | { |
||
9 | /** |
||
10 | * The console command signature. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $signature = 'make:graphql:type {name} {--type= : Create a specific type.}'; |
||
15 | |||
16 | /** |
||
17 | * The console command description. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $description = 'Create a new GraphQL type class'; |
||
22 | |||
23 | /** |
||
24 | * The type of class being generated. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $type = 'Type'; |
||
29 | |||
30 | /** |
||
31 | * The type to create. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $graphqlType = null; |
||
36 | |||
37 | /** |
||
38 | * The list of type and namespaces. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $graphqlTypes = [ |
||
43 | 'AbstractType' => 'Youshido\GraphQL\Type\AbstractType', |
||
44 | 'AbstractScalarType' => 'Youshido\GraphQL\Type\Scalar\AbstractScalarType', |
||
45 | 'AbstractObjectType' => 'Youshido\GraphQL\Type\Object\AbstractObjectType', |
||
46 | 'AbstractMutationObjectType' => 'Youshido\GraphQL\Type\Object\AbstractMutationObjectType', |
||
47 | 'AbstractInputObjectType' => 'Youshido\GraphQL\Type\InputObject\AbstractInputObjectType', |
||
48 | 'AbstractInterfaceType' => 'Youshido\GraphQL\Type\InterfaceType\AbstractInterfaceType', |
||
49 | 'AbstractEnumType' => 'Youshido\GraphQL\Type\Enum\AbstractEnumType', |
||
50 | 'AbstractListType' => 'Youshido\GraphQL\Type\ListType\AbstractListType', |
||
51 | 'AbstractUnionType' => 'Youshido\GraphQL\Type\Union\AbstractUnionType', |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Build the class with the given name. |
||
56 | * |
||
57 | * @param string $name |
||
58 | * @return string |
||
59 | */ |
||
60 | protected function buildClass($name) |
||
69 | |||
70 | /** |
||
71 | * Get the stub file for the generator. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | protected function getStub() |
||
79 | |||
80 | /** |
||
81 | * Get the default namespace for the class. |
||
82 | * |
||
83 | * @param string $rootNamespace |
||
84 | * @return string |
||
85 | */ |
||
86 | protected function getDefaultNamespace($rootNamespace) |
||
90 | |||
91 | /** |
||
92 | * Determine the type to create. |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | protected function determineWhatShouldBeCreated() |
||
108 | |||
109 | /** |
||
110 | * Prompt for which type to create. |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | protected function promptForType() |
||
125 | |||
126 | /** |
||
127 | * Replace the extends type for the given stub. |
||
128 | * |
||
129 | * @param string $stub |
||
130 | * @param string $name |
||
131 | * @return $this |
||
132 | */ |
||
133 | protected function replaceDummy($stub, $name, $dummy) |
||
137 | } |
||
138 |