/Front_End/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php

https://gitlab.com/Sigpot/AirSpot · PHP · 564 lines · 312 code · 46 blank · 206 comment · 2 complexity · 4c904965a6c65a49d5e5fc0eb4a06b72 MD5 · raw file

  1. <?php
  2. namespace Illuminate\Foundation\Providers;
  3. use Illuminate\Support\ServiceProvider;
  4. use Illuminate\Queue\Console\TableCommand;
  5. use Illuminate\Auth\Console\MakeAuthCommand;
  6. use Illuminate\Foundation\Console\UpCommand;
  7. use Illuminate\Foundation\Console\DownCommand;
  8. use Illuminate\Auth\Console\ClearResetsCommand;
  9. use Illuminate\Foundation\Console\ServeCommand;
  10. use Illuminate\Cache\Console\CacheTableCommand;
  11. use Illuminate\Queue\Console\FailedTableCommand;
  12. use Illuminate\Foundation\Console\TinkerCommand;
  13. use Illuminate\Foundation\Console\JobMakeCommand;
  14. use Illuminate\Foundation\Console\AppNameCommand;
  15. use Illuminate\Foundation\Console\OptimizeCommand;
  16. use Illuminate\Foundation\Console\TestMakeCommand;
  17. use Illuminate\Foundation\Console\RouteListCommand;
  18. use Illuminate\Foundation\Console\EventMakeCommand;
  19. use Illuminate\Foundation\Console\ModelMakeCommand;
  20. use Illuminate\Foundation\Console\ViewClearCommand;
  21. use Illuminate\Session\Console\SessionTableCommand;
  22. use Illuminate\Foundation\Console\PolicyMakeCommand;
  23. use Illuminate\Foundation\Console\RouteCacheCommand;
  24. use Illuminate\Foundation\Console\RouteClearCommand;
  25. use Illuminate\Routing\Console\ControllerMakeCommand;
  26. use Illuminate\Routing\Console\MiddlewareMakeCommand;
  27. use Illuminate\Foundation\Console\ConfigCacheCommand;
  28. use Illuminate\Foundation\Console\ConfigClearCommand;
  29. use Illuminate\Foundation\Console\ConsoleMakeCommand;
  30. use Illuminate\Foundation\Console\EnvironmentCommand;
  31. use Illuminate\Foundation\Console\KeyGenerateCommand;
  32. use Illuminate\Foundation\Console\RequestMakeCommand;
  33. use Illuminate\Foundation\Console\ListenerMakeCommand;
  34. use Illuminate\Foundation\Console\ProviderMakeCommand;
  35. use Illuminate\Foundation\Console\ClearCompiledCommand;
  36. use Illuminate\Foundation\Console\EventGenerateCommand;
  37. use Illuminate\Foundation\Console\VendorPublishCommand;
  38. use Illuminate\Database\Console\Seeds\SeederMakeCommand;
  39. class ArtisanServiceProvider extends ServiceProvider
  40. {
  41. /**
  42. * Indicates if loading of the provider is deferred.
  43. *
  44. * @var bool
  45. */
  46. protected $defer = true;
  47. /**
  48. * The commands to be registered.
  49. *
  50. * @var array
  51. */
  52. protected $commands = [
  53. 'ClearCompiled' => 'command.clear-compiled',
  54. 'ClearResets' => 'command.auth.resets.clear',
  55. 'ConfigCache' => 'command.config.cache',
  56. 'ConfigClear' => 'command.config.clear',
  57. 'Down' => 'command.down',
  58. 'Environment' => 'command.environment',
  59. 'KeyGenerate' => 'command.key.generate',
  60. 'Optimize' => 'command.optimize',
  61. 'RouteCache' => 'command.route.cache',
  62. 'RouteClear' => 'command.route.clear',
  63. 'RouteList' => 'command.route.list',
  64. 'Tinker' => 'command.tinker',
  65. 'Up' => 'command.up',
  66. 'ViewClear' => 'command.view.clear',
  67. ];
  68. /**
  69. * The commands to be registered.
  70. *
  71. * @var array
  72. */
  73. protected $devCommands = [
  74. 'AppName' => 'command.app.name',
  75. 'AuthMake' => 'command.auth.make',
  76. 'CacheTable' => 'command.cache.table',
  77. 'ConsoleMake' => 'command.console.make',
  78. 'ControllerMake' => 'command.controller.make',
  79. 'EventGenerate' => 'command.event.generate',
  80. 'EventMake' => 'command.event.make',
  81. 'JobMake' => 'command.job.make',
  82. 'ListenerMake' => 'command.listener.make',
  83. 'MiddlewareMake' => 'command.middleware.make',
  84. 'ModelMake' => 'command.model.make',
  85. 'PolicyMake' => 'command.policy.make',
  86. 'ProviderMake' => 'command.provider.make',
  87. 'QueueFailedTable' => 'command.queue.failed-table',
  88. 'QueueTable' => 'command.queue.table',
  89. 'RequestMake' => 'command.request.make',
  90. 'SeederMake' => 'command.seeder.make',
  91. 'SessionTable' => 'command.session.table',
  92. 'Serve' => 'command.serve',
  93. 'TestMake' => 'command.test.make',
  94. 'VendorPublish' => 'command.vendor.publish',
  95. ];
  96. /**
  97. * Register the service provider.
  98. *
  99. * @return void
  100. */
  101. public function register()
  102. {
  103. $this->registerCommands($this->commands);
  104. $this->registerCommands($this->devCommands);
  105. }
  106. /**
  107. * Register the given commands.
  108. *
  109. * @param array $commands
  110. * @return void
  111. */
  112. protected function registerCommands(array $commands)
  113. {
  114. foreach (array_keys($commands) as $command) {
  115. $method = "register{$command}Command";
  116. call_user_func_array([$this, $method], []);
  117. }
  118. $this->commands(array_values($commands));
  119. }
  120. /**
  121. * Register the command.
  122. *
  123. * @return void
  124. */
  125. protected function registerAppNameCommand()
  126. {
  127. $this->app->singleton('command.app.name', function ($app) {
  128. return new AppNameCommand($app['composer'], $app['files']);
  129. });
  130. }
  131. /**
  132. * Register the command.
  133. *
  134. * @return void
  135. */
  136. protected function registerAuthMakeCommand()
  137. {
  138. $this->app->singleton('command.auth.make', function ($app) {
  139. return new MakeAuthCommand;
  140. });
  141. }
  142. /**
  143. * Register the command.
  144. *
  145. * @return void
  146. */
  147. protected function registerCacheTableCommand()
  148. {
  149. $this->app->singleton('command.cache.table', function ($app) {
  150. return new CacheTableCommand($app['files'], $app['composer']);
  151. });
  152. }
  153. /**
  154. * Register the command.
  155. *
  156. * @return void
  157. */
  158. protected function registerClearCompiledCommand()
  159. {
  160. $this->app->singleton('command.clear-compiled', function () {
  161. return new ClearCompiledCommand;
  162. });
  163. }
  164. /**
  165. * Register the command.
  166. *
  167. * @return void
  168. */
  169. protected function registerClearResetsCommand()
  170. {
  171. $this->app->singleton('command.auth.resets.clear', function () {
  172. return new ClearResetsCommand;
  173. });
  174. }
  175. /**
  176. * Register the command.
  177. *
  178. * @return void
  179. */
  180. protected function registerConfigCacheCommand()
  181. {
  182. $this->app->singleton('command.config.cache', function ($app) {
  183. return new ConfigCacheCommand($app['files']);
  184. });
  185. }
  186. /**
  187. * Register the command.
  188. *
  189. * @return void
  190. */
  191. protected function registerConfigClearCommand()
  192. {
  193. $this->app->singleton('command.config.clear', function ($app) {
  194. return new ConfigClearCommand($app['files']);
  195. });
  196. }
  197. /**
  198. * Register the command.
  199. *
  200. * @return void
  201. */
  202. protected function registerConsoleMakeCommand()
  203. {
  204. $this->app->singleton('command.console.make', function ($app) {
  205. return new ConsoleMakeCommand($app['files']);
  206. });
  207. }
  208. /**
  209. * Register the command.
  210. *
  211. * @return void
  212. */
  213. protected function registerControllerMakeCommand()
  214. {
  215. $this->app->singleton('command.controller.make', function ($app) {
  216. return new ControllerMakeCommand($app['files']);
  217. });
  218. }
  219. /**
  220. * Register the command.
  221. *
  222. * @return void
  223. */
  224. protected function registerEventGenerateCommand()
  225. {
  226. $this->app->singleton('command.event.generate', function () {
  227. return new EventGenerateCommand;
  228. });
  229. }
  230. /**
  231. * Register the command.
  232. *
  233. * @return void
  234. */
  235. protected function registerEventMakeCommand()
  236. {
  237. $this->app->singleton('command.event.make', function ($app) {
  238. return new EventMakeCommand($app['files']);
  239. });
  240. }
  241. /**
  242. * Register the command.
  243. *
  244. * @return void
  245. */
  246. protected function registerDownCommand()
  247. {
  248. $this->app->singleton('command.down', function () {
  249. return new DownCommand;
  250. });
  251. }
  252. /**
  253. * Register the command.
  254. *
  255. * @return void
  256. */
  257. protected function registerEnvironmentCommand()
  258. {
  259. $this->app->singleton('command.environment', function () {
  260. return new EnvironmentCommand;
  261. });
  262. }
  263. /**
  264. * Register the command.
  265. *
  266. * @return void
  267. */
  268. protected function registerJobMakeCommand()
  269. {
  270. $this->app->singleton('command.job.make', function ($app) {
  271. return new JobMakeCommand($app['files']);
  272. });
  273. }
  274. /**
  275. * Register the command.
  276. *
  277. * @return void
  278. */
  279. protected function registerKeyGenerateCommand()
  280. {
  281. $this->app->singleton('command.key.generate', function () {
  282. return new KeyGenerateCommand;
  283. });
  284. }
  285. /**
  286. * Register the command.
  287. *
  288. * @return void
  289. */
  290. protected function registerListenerMakeCommand()
  291. {
  292. $this->app->singleton('command.listener.make', function ($app) {
  293. return new ListenerMakeCommand($app['files']);
  294. });
  295. }
  296. /**
  297. * Register the command.
  298. *
  299. * @return void
  300. */
  301. protected function registerMiddlewareMakeCommand()
  302. {
  303. $this->app->singleton('command.middleware.make', function ($app) {
  304. return new MiddlewareMakeCommand($app['files']);
  305. });
  306. }
  307. /**
  308. * Register the command.
  309. *
  310. * @return void
  311. */
  312. protected function registerModelMakeCommand()
  313. {
  314. $this->app->singleton('command.model.make', function ($app) {
  315. return new ModelMakeCommand($app['files']);
  316. });
  317. }
  318. /**
  319. * Register the command.
  320. *
  321. * @return void
  322. */
  323. protected function registerOptimizeCommand()
  324. {
  325. $this->app->singleton('command.optimize', function ($app) {
  326. return new OptimizeCommand($app['composer']);
  327. });
  328. }
  329. /**
  330. * Register the command.
  331. *
  332. * @return void
  333. */
  334. protected function registerProviderMakeCommand()
  335. {
  336. $this->app->singleton('command.provider.make', function ($app) {
  337. return new ProviderMakeCommand($app['files']);
  338. });
  339. }
  340. /**
  341. * Register the command.
  342. *
  343. * @return void
  344. */
  345. protected function registerQueueFailedTableCommand()
  346. {
  347. $this->app->singleton('command.queue.failed-table', function ($app) {
  348. return new FailedTableCommand($app['files'], $app['composer']);
  349. });
  350. }
  351. /**
  352. * Register the command.
  353. *
  354. * @return void
  355. */
  356. protected function registerQueueTableCommand()
  357. {
  358. $this->app->singleton('command.queue.table', function ($app) {
  359. return new TableCommand($app['files'], $app['composer']);
  360. });
  361. }
  362. /**
  363. * Register the command.
  364. *
  365. * @return void
  366. */
  367. protected function registerRequestMakeCommand()
  368. {
  369. $this->app->singleton('command.request.make', function ($app) {
  370. return new RequestMakeCommand($app['files']);
  371. });
  372. }
  373. /**
  374. * Register the command.
  375. *
  376. * @return void
  377. */
  378. protected function registerSeederMakeCommand()
  379. {
  380. $this->app->singleton('command.seeder.make', function ($app) {
  381. return new SeederMakeCommand($app['files'], $app['composer']);
  382. });
  383. }
  384. /**
  385. * Register the command.
  386. *
  387. * @return void
  388. */
  389. protected function registerSessionTableCommand()
  390. {
  391. $this->app->singleton('command.session.table', function ($app) {
  392. return new SessionTableCommand($app['files'], $app['composer']);
  393. });
  394. }
  395. /**
  396. * Register the command.
  397. *
  398. * @return void
  399. */
  400. protected function registerRouteCacheCommand()
  401. {
  402. $this->app->singleton('command.route.cache', function ($app) {
  403. return new RouteCacheCommand($app['files']);
  404. });
  405. }
  406. /**
  407. * Register the command.
  408. *
  409. * @return void
  410. */
  411. protected function registerRouteClearCommand()
  412. {
  413. $this->app->singleton('command.route.clear', function ($app) {
  414. return new RouteClearCommand($app['files']);
  415. });
  416. }
  417. /**
  418. * Register the command.
  419. *
  420. * @return void
  421. */
  422. protected function registerRouteListCommand()
  423. {
  424. $this->app->singleton('command.route.list', function ($app) {
  425. return new RouteListCommand($app['router']);
  426. });
  427. }
  428. /**
  429. * Register the command.
  430. *
  431. * @return void
  432. */
  433. protected function registerServeCommand()
  434. {
  435. $this->app->singleton('command.serve', function () {
  436. return new ServeCommand;
  437. });
  438. }
  439. /**
  440. * Register the command.
  441. *
  442. * @return void
  443. */
  444. protected function registerTestMakeCommand()
  445. {
  446. $this->app->singleton('command.test.make', function ($app) {
  447. return new TestMakeCommand($app['files']);
  448. });
  449. }
  450. /**
  451. * Register the command.
  452. *
  453. * @return void
  454. */
  455. protected function registerTinkerCommand()
  456. {
  457. $this->app->singleton('command.tinker', function () {
  458. return new TinkerCommand;
  459. });
  460. }
  461. /**
  462. * Register the command.
  463. *
  464. * @return void
  465. */
  466. protected function registerUpCommand()
  467. {
  468. $this->app->singleton('command.up', function () {
  469. return new UpCommand;
  470. });
  471. }
  472. /**
  473. * Register the command.
  474. *
  475. * @return void
  476. */
  477. protected function registerVendorPublishCommand()
  478. {
  479. $this->app->singleton('command.vendor.publish', function ($app) {
  480. return new VendorPublishCommand($app['files']);
  481. });
  482. }
  483. /**
  484. * Register the command.
  485. *
  486. * @return void
  487. */
  488. protected function registerViewClearCommand()
  489. {
  490. $this->app->singleton('command.view.clear', function ($app) {
  491. return new ViewClearCommand($app['files']);
  492. });
  493. }
  494. /**
  495. * Register the command.
  496. *
  497. * @return void
  498. */
  499. protected function registerPolicyMakeCommand()
  500. {
  501. $this->app->singleton('command.policy.make', function ($app) {
  502. return new PolicyMakeCommand($app['files']);
  503. });
  504. }
  505. /**
  506. * Get the services provided by the provider.
  507. *
  508. * @return array
  509. */
  510. public function provides()
  511. {
  512. if ($this->app->environment('production')) {
  513. return array_values($this->commands);
  514. } else {
  515. return array_merge(array_values($this->commands), array_values($this->devCommands));
  516. }
  517. }
  518. }