3 namespace DrupalCodeGenerator\Command\Other;
5 use DrupalCodeGenerator\Command\BaseGenerator;
6 use DrupalCodeGenerator\Utils;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\Question;
12 * Implements other:dcg-command command.
14 class DcgCommand extends BaseGenerator {
16 protected $name = 'other:dcg-command';
17 protected $description = 'Generates DCG command';
18 protected $alias = 'dcg-command';
19 protected $label = 'DCG command';
24 protected function configure() {
25 $this->destination = Utils::getHomeDirectory() . '/.dcg/Command';
32 protected function interact(InputInterface $input, OutputInterface $output) {
35 'name' => new Question('Command name', 'custom:example'),
36 'description' => new Question('Command description', 'Some description'),
37 'alias' => new Question('Command alias', 'example'),
40 $vars = &$this->collectVars($input, $output, $questions);
42 $sub_names = explode(':', $vars['name']);
43 $last_sub_name = array_pop($sub_names);
44 $vars['class'] = Utils::camelize($last_sub_name);
45 $vars['namespace'] = 'DrupalCodeGenerator\Command';
46 $vars['template_name'] = $last_sub_name . '.twig';
51 $vars['namespace'] .= '\\' . implode('\\', $sub_names);
52 $file_path = implode(DIRECTORY_SEPARATOR, $sub_names);
53 $vars['path'] = '/' . $file_path;
57 ->path($file_path . '/{class}.php')
58 ->template('other/dcg-command.twig');
61 ->path($file_path . '/{template_name}')
62 ->template('other/dcg-command-template.twig');