1 | <?php |
||
7 | class WidgetGenerator extends LaravelGeneratorCommand |
||
8 | { |
||
9 | /** |
||
10 | * The name and signature of the console command. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $signature = 'make:widget {name : The name of the widget class} {--p|plain}'; |
||
15 | |||
16 | /** |
||
17 | * The console command description. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $description = 'Create a new widget class'; |
||
22 | |||
23 | /** |
||
24 | * String to store the command type. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $type = 'Widget Class'; |
||
29 | |||
30 | /** |
||
31 | * Execute the console command. |
||
32 | * |
||
33 | * @return void |
||
34 | */ |
||
35 | public function fire() |
||
43 | |||
44 | /** |
||
45 | * Create a new view file for the widget. |
||
46 | * |
||
47 | * return void |
||
48 | */ |
||
49 | private function createView() |
||
63 | |||
64 | /** |
||
65 | * Get the stub file for the generator. |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function getStub() |
||
70 | { |
||
71 | $stubName = $this->option('plain') ? 'widget_plain' : 'widget'; |
||
72 | |||
73 | return __DIR__."/../stubs/$stubName.stub"; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Get the default namespace for the class. |
||
78 | * |
||
79 | * @param string $rootNamespace |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | protected function getDefaultNamespace($rootNamespace) |
||
84 | { |
||
85 | return $rootNamespace.'\\Widgets'; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Get the console command options. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | protected function getOptions() |
||
99 | |||
100 | /** |
||
101 | * @return string |
||
102 | */ |
||
103 | private function getViewPath() |
||
111 | |||
112 | /** |
||
113 | * Creates the widget class. |
||
114 | * @return bool |
||
115 | */ |
||
116 | private function makeWidgetClass() |
||
140 | |||
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | private function getViewStub() |
||
148 | } |
||
149 |