mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Get generate:extension command working again
This commit is contained in:
parent
5f23e8c447
commit
91c5cef521
|
@ -3,6 +3,7 @@
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
|
||||||
class GenerateExtensionCommand extends Command
|
class GenerateExtensionCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -32,14 +33,14 @@ class GenerateExtensionCommand extends Command
|
||||||
*/
|
*/
|
||||||
protected function fire()
|
protected function fire()
|
||||||
{
|
{
|
||||||
do {
|
|
||||||
$vendor = $this->ask('Vendor name:');
|
|
||||||
} while (! preg_match('/^([a-z0-9-]+)$/i', $vendor));
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$name = $this->ask('Extension name:');
|
$name = $this->ask('Extension name:');
|
||||||
} while (! preg_match('/^([a-z0-9-]+)$/i', $name));
|
} while (! preg_match('/^([a-z0-9-]+)$/i', $name));
|
||||||
|
|
||||||
|
do {
|
||||||
|
$namespace = $this->ask('Namespace:');
|
||||||
|
} while (! preg_match('/^([a-z0-9_\\\\]+)$/i', $namespace));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$title = $this->ask('Title:');
|
$title = $this->ask('Title:');
|
||||||
} while (! $title);
|
} while (! $title);
|
||||||
|
@ -57,8 +58,8 @@ class GenerateExtensionCommand extends Command
|
||||||
$dir = public_path().'/extensions/'.$name;
|
$dir = public_path().'/extensions/'.$name;
|
||||||
|
|
||||||
$replacements = [
|
$replacements = [
|
||||||
'{{namespace}}' => ucfirst($vendor).'\\'.ucfirst($name),
|
'{{namespace}}' => $namespace,
|
||||||
'{{escapedNamespace}}' => ucfirst($vendor).'\\\\'.ucfirst($name),
|
'{{escapedNamespace}}' => str_replace('\\', '\\\\', $namespace),
|
||||||
'{{name}}' => $name
|
'{{name}}' => $name
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -88,6 +89,13 @@ class GenerateExtensionCommand extends Command
|
||||||
$this->info('Extension "'.$name.'" generated!');
|
$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 = [])
|
protected function copyStub($destination, $replacements = [])
|
||||||
{
|
{
|
||||||
$this->recursiveCopy(__DIR__.'/../../stubs/extension', $destination, $replacements);
|
$this->recursiveCopy(__DIR__.'/../../stubs/extension', $destination, $replacements);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user