Skip to content

Commit 8c8708d

Browse files
committed
Clean-up base generators
1 parent c6cbb8a commit 8c8708d

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

src/Command/DrupalGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function askNameQuestion() :string {
101101
$root_directory = basename(Utils::getExtensionRoot($this->directory) ?: $this->directory);
102102
$default_value = Utils::machine2human($root_directory);
103103
$name_question = new Question($this->nameQuestion, $default_value);
104-
$name_question->setValidator([__CLASS__, 'validateRequired']);
104+
$name_question->setValidator([get_class($this), 'validateRequired']);
105105
if (!$this->isNewExtension && $extensions = $this->getExtensionList()) {
106106
$name_question->setAutocompleterValues($extensions);
107107
}
@@ -114,7 +114,7 @@ protected function askNameQuestion() :string {
114114
protected function askMachineNameQuestion() :string {
115115
$default_value = Utils::human2machine($this->vars['name'] ?? basename($this->directory));
116116
$machine_name_question = new Question($this->machineNameQuestion, $default_value);
117-
$machine_name_question->setValidator([__CLASS__, 'validateRequiredMachineName']);
117+
$machine_name_question->setValidator([get_class($this), 'validateRequiredMachineName']);
118118
if (!$this->isNewExtension && $extensions = $this->getExtensionList()) {
119119
$machine_name_question->setAutocompleterValues(array_keys($extensions));
120120
}

src/Command/Generator.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,14 @@ abstract class Generator extends Command implements GeneratorInterface, IOAwareI
8989
/**
9090
* {@inheritdoc}
9191
*/
92-
protected function configure():void {
92+
protected function configure() :void {
9393
$this
9494
->setName($this->name)
9595
->setDescription($this->description)
96-
->addOption(
97-
'directory',
98-
'-d',
99-
InputOption::VALUE_OPTIONAL,
100-
'Working directory'
101-
)
102-
->addOption(
103-
'answer',
104-
'-a',
105-
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
106-
'Answer to generator question'
107-
)
108-
->addOption(
109-
'dry-run',
110-
NULL,
111-
InputOption::VALUE_NONE,
112-
'Output the generated code but not save it to file system'
113-
);
114-
115-
if ($this->alias) {
116-
$this->setAliases([$this->alias]);
117-
}
96+
->addOption('directory', '-d', InputOption::VALUE_OPTIONAL, 'Working directory')
97+
->addOption('answer', '-a', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Answer to generator question')
98+
->addOption('dry-run', NULL, InputOption::VALUE_NONE, 'Output the generated code but not save it to file system')
99+
->setAliases($this->alias ? [$this->alias] : []);
118100
}
119101

120102
/**
@@ -221,7 +203,7 @@ protected function ask(string $question, $default = NULL, $validator = NULL) {
221203
// Allow the validators to be referenced in a short form like
222204
// '::validateMachineName'.
223205
if (is_string($validator) && substr($validator, 0, 2) == '::') {
224-
$validator = [__CLASS__, substr($validator, 2)];
206+
$validator = [get_class($this), substr($validator, 2)];
225207
}
226208
return $this->io->ask($question, $default, $validator);
227209
}

0 commit comments

Comments
 (0)