|
4 | 4 |
|
5 | 5 | class InstallCommand extends Command { |
6 | 6 |
|
7 | | - protected $name = 'forum:install'; |
8 | | - protected $description = 'Create default forum controllers.'; |
9 | | - |
10 | | - public function fire() |
11 | | - { |
12 | | - $this->info('Fetching controller names from integration config...'); |
13 | | - $controller = class_basename(\Config::get('forum::integration.controller')); |
14 | | - |
15 | | - $this->info('Config specifies controllers: "'.$controller.'"'); |
16 | | - if (!$this->confirm('Proceed with controller creation (no override)? [Yes|no]')) |
17 | | - { |
18 | | - $this->info('Action aborted. No changes done.'); |
19 | | - return; |
20 | | - } |
21 | | - |
22 | | - $this->installController($controller, '\Riari\Forum\Controllers\BaseController'); |
23 | | - |
24 | | - $this->info('Forum installation done.'); |
25 | | - } |
26 | | - |
27 | | - private function installController($name, $parent) |
28 | | - { |
29 | | - $file = $this->laravel->path.'/controllers/'.$name.'.php'; |
30 | | - if(file_exists($file)) |
31 | | - { |
32 | | - $this->info('File app/controllers/'.$name.' Exists. Action aborted.'); |
33 | | - return; |
34 | | - } |
35 | | - |
36 | | - file_put_contents($file, $this->getControllerContent($name, $parent)); |
37 | | - $this->info('File app/controllers/'.$name.' Created'); |
38 | | - } |
39 | | - |
40 | | - public function getControllerContent($name, $parent) |
41 | | - { |
42 | | - $content = "<?php\n" |
43 | | - ."/* Autogenerated Forum Controller */\n" |
44 | | - ."/* Hook point of the Forum package inside your laravel application */\n" |
45 | | - ."/* Feel free to override methods here to fit your requirements */\n" |
46 | | - ."class %s extends %s {\n\n" |
47 | | - ."}\n"; |
48 | | - |
49 | | - return sprintf($content, $name, $parent); |
50 | | - } |
| 7 | + protected $name = 'forum:install'; |
| 8 | + protected $description = 'Create default forum controllers.'; |
| 9 | + |
| 10 | + public function fire() |
| 11 | + { |
| 12 | + $this->info('Fetching controller names from integration config...'); |
| 13 | + $controller = class_basename(\Config::get('forum::integration.controller')); |
| 14 | + |
| 15 | + $this->info('Config specifies controllers: "'.$controller.'"'); |
| 16 | + if (!$this->confirm('Proceed with controller creation (no override)? [Yes|no]')) |
| 17 | + { |
| 18 | + $this->info('Action aborted. No changes done.'); |
| 19 | + return; |
| 20 | + } |
| 21 | + |
| 22 | + $this->installController($controller, '\Riari\Forum\Controllers\BaseController'); |
| 23 | + |
| 24 | + $this->info('Forum installation done.'); |
| 25 | + } |
| 26 | + |
| 27 | + private function installController($name, $parent) |
| 28 | + { |
| 29 | + $file = $this->laravel->path.'/controllers/'.$name.'.php'; |
| 30 | + if(file_exists($file)) |
| 31 | + { |
| 32 | + $this->info('File app/controllers/'.$name.' Exists. Action aborted.'); |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + file_put_contents($file, $this->getControllerContent($name, $parent)); |
| 37 | + $this->info('File app/controllers/'.$name.' Created'); |
| 38 | + } |
| 39 | + |
| 40 | + public function getControllerContent($name, $parent) |
| 41 | + { |
| 42 | + $content = "<?php\n" |
| 43 | + ."/* Autogenerated Forum Controller */\n" |
| 44 | + ."/* Hook point of the Forum package inside your laravel application */\n" |
| 45 | + ."/* Feel free to override methods here to fit your requirements */\n" |
| 46 | + ."class %s extends %s {\n\n" |
| 47 | + ."}\n"; |
| 48 | + |
| 49 | + return sprintf($content, $name, $parent); |
| 50 | + } |
51 | 51 |
|
52 | 52 | } |
0 commit comments