-
-
Notifications
You must be signed in to change notification settings - Fork 547
Expand file tree
/
Copy pathcommand.php.twig
More file actions
84 lines (74 loc) · 2.02 KB
/
command.php.twig
File metadata and controls
84 lines (74 loc) · 2.02 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{% extends "base/class.php.twig" %}
{% block file_path %}
\Drupal\{{extension}}\Command\{{ class }}.
{% endblock %}
{% block namespace_class %}
namespace Drupal\{{extension}}\Command;
{% endblock %}
{% block use_class %}
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
{% if container_aware %}
use Drupal\Console\Core\Command\ContainerAwareCommand;
{% else %}
use Drupal\Console\Core\Command\Command;
{% endif %}
{% endblock %}
{% block class_declaration %}
/**
* Class {{ class_name }}.
*
* @Drupal\Console\Annotations\DrupalCommand (
* extension="{{extension}}",
* extensionType="{{ extension_type }}"
* )
*/
class {{ class_name }} extends {% if container_aware %}ContainerAwareCommand{% else %}Command{% endif %} {% endblock %}
{% block class_construct %}
{% if services is not empty %}
/**
* Constructs a new {{ class_name }} object.
*/
public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
{{ serviceClassInitialization(services) }}
parent::__construct();
}
{% endif %}
{% endblock %}
{% block class_methods %}
/**
* {@inheritdoc}
*/
protected function configure() {
$this
->setName('{{ name }}')
->setDescription($this->trans('commands.{{ command_key }}.description'));
}
{% if initialize %}
/**
* {@inheritdoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output) {
parent::initialize($input, $output);
$this->getIo()->info('initialize');
}
{% endif %}
{% if interact %}
/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output) {
$this->getIo()->info('interact');
}
{% endif %}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$this->getIo()->info('execute');
$this->getIo()->info($this->trans('commands.{{ command_key }}.messages.success'));
{% if class_generator %}
$this->generator->generate([]);
{% endif %}
}
{% endblock %}