Get generate:extension command working again

This commit is contained in:
Toby Zerner 2015-08-18 13:56:25 +09:30
parent edccd10693
commit 71c7740086

View File

@ -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);