1 | <?php |
||
35 | class ImplementCommand extends GenericInlineConfigCommand implements InlineConfigCommandInterface |
||
36 | { |
||
37 | use |
||
38 | UsesInterfaceTrait, |
||
39 | UsesBehaviorTrait, |
||
40 | HasContainerTrait; |
||
41 | |||
42 | /** |
||
43 | * CONFIG |
||
44 | */ |
||
45 | public const NAME = 'behavior:implement'; |
||
46 | public const DESCRIPTION = 'Creates a Trait from a given Interface'; |
||
47 | public const HIDDEN = false; |
||
48 | public const USAGES = [ '@todo' ]; |
||
49 | public const HELP = <<<EOF |
||
50 | The <info>%command.name%</info> command creates an trait from a given interface: |
||
51 | <info>php %command.full_name% ClassName MethodName</info> |
||
52 | Will generate an example in the ClassNameSpec. |
||
53 | EOF; |
||
54 | |||
55 | public const ARGUMENTS = [ |
||
56 | self::INTERFACE_INPUT => [ |
||
57 | self::MODE_KEY => InputArgument::REQUIRED, |
||
58 | self::DESCRIPTION_KEY => 'Interface to create behavior for' |
||
59 | ], |
||
60 | self::TRAIT_INPUT => [ |
||
61 | self::MODE_KEY => InputArgument::OPTIONAL, |
||
62 | self::DESCRIPTION_KEY => 'Custom trait class name' |
||
63 | ] |
||
64 | ]; |
||
65 | |||
66 | public const OPTIONS = [ |
||
67 | self::FORCE_KEY => [ |
||
68 | self::MODE_KEY => InputOption::VALUE_NONE, |
||
69 | self::DESCRIPTION_KEY => 'Force creation of Trait without asking for confirmation' |
||
70 | ] |
||
71 | ]; |
||
72 | |||
73 | protected const INTERFACE_CONFIRMATION_QUESTION = 'Interface %s? does not exist. Do you want to generate it?'; |
||
74 | protected const TRAIT_CONFIRMATION_QUESTION = 'Do you want to generate a Trait for Interface %s?'; |
||
75 | |||
76 | protected const INTERFACE_INPUT = 'interface'; |
||
77 | protected const TRAIT_INPUT = 'trait'; |
||
78 | |||
79 | protected const MODE_KEY = 'mode'; |
||
80 | protected const DESCRIPTION_KEY = 'description'; |
||
81 | protected const FORCE_KEY = 'force'; |
||
82 | |||
83 | protected const RESOURCE_MANAGER_ID = 'locator.resource_manager'; |
||
84 | protected const CODE_GENERATOR_ID = 'code_generator'; |
||
85 | |||
86 | /** |
||
87 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
88 | * @param OutputInterface $output |
||
89 | * |
||
90 | * @return int|null |
||
91 | */ |
||
92 | protected function execute(InputInterface $input, OutputInterface $output) |
||
119 | |||
120 | /** |
||
121 | * @param string $interfaceName |
||
122 | * @return bool |
||
123 | */ |
||
124 | private function confirmInterfaceGeneration(string $interfaceName) |
||
133 | |||
134 | /** |
||
135 | * @param string $interfaceName |
||
136 | * @param null|string $traitName |
||
137 | * @return bool |
||
138 | */ |
||
139 | private function confirmTraitGeneration(string $interfaceName, ? string $traitName) |
||
149 | |||
150 | /** |
||
151 | * @return object|ResourceManager |
||
152 | */ |
||
153 | protected function retrieveResourceManager() |
||
157 | |||
158 | /** |
||
159 | * @return object|Generator |
||
160 | */ |
||
161 | protected function retrieveCodeGenerator() |
||
165 | } |
||
166 | |||
167 |