www.gusucode.com > KPPW众包威客PHP开源建站系统 v3.0源码程序 > KPPW/vendor/caffeinated/modules/src/Console/Generators/MakeControllerCommand.php
<?php namespace Caffeinated\Modules\Console\Generators; class MakeControllerCommand extends MakeCommand { /** * The name and signature of the console command. * * @var string */ protected $signature = 'make:module:controller {slug : The slug of the module} {name : The name of the controller class} {--resource : Generate a module resource controller class}'; /** * The console command description. * * @var string */ protected $description = 'Create a new module controller class'; /** * String to store the command type. * * @var string */ protected $type = 'Controller'; /** * Module folders to be created. * * @var array */ protected $listFolders = [ 'Http/Controllers/', ]; /** * Module files to be created. * * @var array */ protected $listFiles = [ '{{filename}}.php', ]; /** * Module signature option. * * @var array */ protected $signOption = [ 'resource', ]; /** * Module stubs used to populate defined files. * * @var array */ protected $listStubs = [ 'default' => [ 'controller.stub', ], 'resource' => [ 'controller_resource.stub', ], ]; /** * Resolve Container after getting file path. * * @param string $FilePath * * @return array */ protected function resolveByPath($filePath) { $this->container['filename'] = $this->makeFileName($filePath); $this->container['namespace'] = $this->getNamespace($filePath); $this->container['path'] = $this->getBaseNamespace(); $this->container['classname'] = basename($filePath); } /** * Replace placeholder text with correct values. * * @return string */ protected function formatContent($content) { return str_replace( [ '{{filename}}', '{{path}}', '{{namespace}}', '{{classname}}', ], [ $this->container['filename'], $this->container['path'], $this->container['namespace'], $this->container['classname'], ], $content ); } }