1 | <?php |
||
14 | class PublishAdminLTE extends Command |
||
15 | { |
||
16 | /** |
||
17 | * The filesystem instance. |
||
18 | * |
||
19 | * @var \Illuminate\Filesystem\Filesystem |
||
20 | */ |
||
21 | protected $files; |
||
22 | |||
23 | /** |
||
24 | * The name and signature of the console command. |
||
25 | */ |
||
26 | protected $signature = 'adminlte-laravel:publish {--f|force : Force overwrite of files}'; |
||
27 | |||
28 | /** |
||
29 | * The console command description. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $description = 'Publish Acacha AdminLTE Template files into laravel project'; |
||
34 | |||
35 | /** |
||
36 | * Force overwrite of files. |
||
37 | * |
||
38 | * @var bool |
||
39 | */ |
||
40 | protected $force = false; |
||
41 | |||
42 | /** |
||
43 | * Create a new command instance. |
||
44 | * |
||
45 | * @param \Illuminate\Filesystem\Filesystem $files |
||
46 | * |
||
47 | * @return void |
||
|
|||
48 | */ |
||
49 | public function __construct(Filesystem $files) |
||
54 | |||
55 | /** |
||
56 | * Execute the console command. |
||
57 | */ |
||
58 | public function handle() |
||
59 | { |
||
60 | $this->processOptions(); |
||
61 | $this->publishHomeController(); |
||
62 | $this->changeRegisterController(); |
||
63 | $this->changeLoginController(); |
||
64 | $this->changeForgotPasswordController(); |
||
65 | $this->changeResetPasswordController(); |
||
66 | $this->publishPublicAssets(); |
||
67 | $this->publishViews(); |
||
68 | $this->publishResourceAssets(); |
||
69 | $this->publishTests(); |
||
70 | $this->publishLanguages(); |
||
71 | $this->publishGravatar(); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Install Home Controller. |
||
76 | */ |
||
77 | private function publishHomeController() |
||
81 | |||
82 | /** |
||
83 | * Change Auth Register controller. |
||
84 | */ |
||
85 | private function changeRegisterController() |
||
89 | |||
90 | /** |
||
91 | * Change Auth Login controller. |
||
92 | */ |
||
93 | private function changeLoginController() |
||
97 | |||
98 | /** |
||
99 | * Change Auth Forgot Password controller. |
||
100 | */ |
||
101 | private function changeForgotPasswordController() |
||
105 | |||
106 | /** |
||
107 | * Change Auth Reset Password controller. |
||
108 | */ |
||
109 | private function changeResetPasswordController() |
||
113 | |||
114 | /** |
||
115 | * Install public assets. |
||
116 | */ |
||
117 | private function publishPublicAssets() |
||
121 | |||
122 | /** |
||
123 | * Install views. |
||
124 | */ |
||
125 | private function publishViews() |
||
129 | |||
130 | /** |
||
131 | * Install resource assets. |
||
132 | */ |
||
133 | private function publishResourceAssets() |
||
137 | |||
138 | /** |
||
139 | * Install resource assets. |
||
140 | */ |
||
141 | private function publishTests() |
||
145 | |||
146 | /** |
||
147 | * Install language assets. |
||
148 | */ |
||
149 | private function publishLanguages() |
||
153 | |||
154 | /** |
||
155 | * Install gravatar config file. |
||
156 | */ |
||
157 | private function publishGravatar() |
||
161 | |||
162 | /** |
||
163 | * Install files from array. |
||
164 | * |
||
165 | * @param $files |
||
166 | */ |
||
167 | private function install($files) |
||
182 | |||
183 | /** |
||
184 | * @param $fileName |
||
185 | * @param string $prompt |
||
186 | * |
||
187 | * @return bool |
||
188 | */ |
||
189 | protected function confirmOverwrite($fileName, $prompt = '') |
||
197 | |||
198 | /** |
||
199 | * Create the directory to house the published files if needed. |
||
200 | * |
||
201 | * @param string $directory |
||
202 | * |
||
203 | * @return void |
||
204 | */ |
||
205 | protected function createParentDirectory($directory) |
||
211 | |||
212 | /** |
||
213 | * Publish the file to the given path. |
||
214 | * |
||
215 | * @param string $from |
||
216 | * @param string $to |
||
217 | * |
||
218 | * @return void |
||
219 | */ |
||
220 | protected function publishFile($from, $to) |
||
226 | |||
227 | /** |
||
228 | * Publish the directory to the given directory. |
||
229 | * |
||
230 | * @param string $from |
||
231 | * @param string $to |
||
232 | * |
||
233 | * @return void |
||
234 | */ |
||
235 | protected function publishDirectory($from, $to) |
||
236 | { |
||
237 | $manager = new MountManager([ |
||
238 | 'from' => new Flysystem(new LocalAdapter($from)), |
||
239 | 'to' => new Flysystem(new LocalAdapter($to)), |
||
240 | ]); |
||
241 | foreach ($manager->listContents('from://', true) as $file) { |
||
242 | if ($file['type'] === 'file' && (!$manager->has('to://'.$file['path']) || $this->force )) { |
||
243 | $manager->put('to://'.$file['path'], $manager->read('from://'.$file['path'])); |
||
244 | } |
||
245 | } |
||
246 | $this->status($from, $to, 'Directory'); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Write a status message to the console. |
||
251 | * |
||
252 | * @param string $from |
||
253 | * @param string $to |
||
254 | * @param string $type |
||
255 | * |
||
256 | * @return void |
||
257 | */ |
||
258 | protected function status($from, $to, $type) |
||
264 | |||
265 | /** |
||
266 | * Process options before running command. |
||
267 | */ |
||
268 | private function processOptions() |
||
272 | } |
||
273 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.