mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:25:28 +08:00
Get generate:extension command working again
This commit is contained in:
parent
edccd10693
commit
71c7740086
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Contracts\Container\Container;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
class GenerateExtensionCommand extends Command
|
||||
{
|
||||
|
@ -32,14 +33,14 @@ class GenerateExtensionCommand extends Command
|
|||
*/
|
||||
protected function fire()
|
||||
{
|
||||
do {
|
||||
$vendor = $this->ask('Vendor name:');
|
||||
} while (! preg_match('/^([a-z0-9-]+)$/i', $vendor));
|
||||
|
||||
do {
|
||||
$name = $this->ask('Extension name:');
|
||||
} while (! preg_match('/^([a-z0-9-]+)$/i', $name));
|
||||
|
||||
do {
|
||||
$namespace = $this->ask('Namespace:');
|
||||
} while (! preg_match('/^([a-z0-9_\\\\]+)$/i', $namespace));
|
||||
|
||||
do {
|
||||
$title = $this->ask('Title:');
|
||||
} while (! $title);
|
||||
|
@ -57,8 +58,8 @@ class GenerateExtensionCommand extends Command
|
|||
$dir = public_path().'/extensions/'.$name;
|
||||
|
||||
$replacements = [
|
||||
'{{namespace}}' => ucfirst($vendor).'\\'.ucfirst($name),
|
||||
'{{escapedNamespace}}' => ucfirst($vendor).'\\\\'.ucfirst($name),
|
||||
'{{namespace}}' => $namespace,
|
||||
'{{escapedNamespace}}' => str_replace('\\', '\\\\', $namespace),
|
||||
'{{name}}' => $name
|
||||
];
|
||||
|
||||
|
@ -88,6 +89,13 @@ class GenerateExtensionCommand extends Command
|
|||
$this->info('Extension "'.$name.'" generated!');
|
||||
}
|
||||
|
||||
protected function ask($question, $default = null)
|
||||
{
|
||||
$question = new Question("<question>$question</question> ", $default);
|
||||
|
||||
return $this->getHelperSet()->get('question')->ask($this->input, $this->output, $question);
|
||||
}
|
||||
|
||||
protected function copyStub($destination, $replacements = [])
|
||||
{
|
||||
$this->recursiveCopy(__DIR__.'/../../stubs/extension', $destination, $replacements);
|
||||
|
|
Loading…
Reference in New Issue
Block a user