Viewing file: ControllerMakeCommand.php (1.74 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace Illuminate\Routing\Console;
use Illuminate\Console\GeneratorCommand; use Symfony\Component\Console\Input\InputOption;
class ControllerMakeCommand extends GeneratorCommand { /** * The console command name. * * @var string */ protected $name = 'make:controller';
/** * The console command description. * * @var string */ protected $description = 'Create a new controller class';
/** * The type of class being generated. * * @var string */ protected $type = 'Controller';
/** * Get the stub file for the generator. * * @return string */ protected function getStub() { if ($this->option('resource')) { return __DIR__.'/stubs/controller.stub'; }
return __DIR__.'/stubs/controller.plain.stub'; }
/** * Get the default namespace for the class. * * @param string $rootNamespace * @return string */ protected function getDefaultNamespace($rootNamespace) { return $rootNamespace.'\Http\Controllers'; }
/** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['resource', null, InputOption::VALUE_NONE, 'Generate a resource controller class.'], ]; }
/** * Build the class with the given name. * * Remove the base controller import if we are already in base namespace. * * @param string $name * @return string */ protected function buildClass($name) { $namespace = $this->getNamespace($name);
return str_replace("use $namespace\Controller;\n", '', parent::buildClass($name)); } }
|