forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandGenerator.php
More file actions
45 lines (39 loc) · 1.38 KB
/
Copy pathCommandGenerator.php
File metadata and controls
45 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* @file
* Contains \Drupal\AppConsole\Generator\CommandGenerator.
*/
namespace Drupal\AppConsole\Generator;
class CommandGenerator extends Generator
{
/**
* Generator Plugin Block
* @param string $module Module name
* @param string $command Command name
* @param string $class_name class name for plugin block
* @param array $container Access to container class
*/
public function generate($module, $command, $class_name, $container)
{
$command_key_root = 'command.' . str_replace(':', '.', $command);
$parameters = [
'module_name' => $module,
'command' => $command,
'name' => [
'class' => $class_name,
],
'container' => $container,
'command_key_root' => $command_key_root
];
$messages[$command_key_root . '.description'] = 'Greet someone';
$messages[$command_key_root . '.arguments.name'] = 'Who do you want to greet?';
$messages[$command_key_root . '.options.yell'] = 'If set, the task will yell in uppercase letters';
$translator = $this->getTranslator();
$translator->writeTranslationsByModule($module, $messages);
$this->renderFile(
'module/src/Command/command.php.twig',
$this->getCommandPath($module) . '/' . $class_name . '.php',
$parameters
);
}
}