Controller.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 刘志淳 <chun@engineer.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\console\command\make;
  12. use think\Config;
  13. use think\console\command\Make;
  14. use think\console\input\Option;
  15. class Controller extends Make
  16. {
  17. protected $type = "Controller";
  18. protected function configure()
  19. {
  20. parent::configure();
  21. $this->setName('make:controller')
  22. ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.')
  23. ->setDescription('Create a new resource controller class');
  24. }
  25. protected function getStub()
  26. {
  27. if ($this->input->getOption('plain')) {
  28. return __DIR__ . '/stubs/controller.plain.stub';
  29. }
  30. return __DIR__ . '/stubs/controller.stub';
  31. }
  32. protected function getClassName($name)
  33. {
  34. return parent::getClassName($name) . (Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : '');
  35. }
  36. protected function getNamespace($appNamespace, $module)
  37. {
  38. return parent::getNamespace($appNamespace, $module) . '\controller';
  39. }
  40. }