1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scaffolder; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Scaffolder\Commands\ClearCacheCommand; |
7
|
|
|
use Scaffolder\Commands\GeneratorCommand; |
8
|
|
|
use Scaffolder\Commands\ServeCommand; |
9
|
|
|
use Scaffolder\Commands\BuildCommand; |
10
|
|
|
|
11
|
|
|
class ScaffolderServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bootstrap the application services. |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
// Scaffolder config |
19
|
|
|
$this->publishes([ |
20
|
|
|
__DIR__ . '/../../config/' => base_path('scaffolder-config/') |
21
|
|
|
], 'config'); |
22
|
|
|
|
23
|
|
|
// Generator views |
24
|
|
|
//$this->loadViewsFrom(__DIR__ . '/../../views', 'scaffolder'); |
|
|
|
|
25
|
|
|
|
26
|
|
|
// Generator routes |
27
|
|
|
if (!$this->app->routesAreCached()) |
28
|
|
|
{ |
29
|
|
|
require __DIR__ . '/../../routes/generator.php'; |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Register the service provider. |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
public function register() |
39
|
|
|
{ |
40
|
|
|
$this->app->singleton('scaffolder.command.generate', function ($app) |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
return new GeneratorCommand(); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
$this->app->singleton('scaffolder.command.cache.clear', function () |
46
|
|
|
{ |
47
|
|
|
return new ClearCacheCommand(); |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
$this->app->singleton('scaffolder.command.build', function () |
51
|
|
|
{ |
52
|
|
|
return new BuildCommand(); |
53
|
|
|
}); |
54
|
|
|
|
55
|
|
|
$this->app->singleton('scaffolder.command.serve', function () |
56
|
|
|
{ |
57
|
|
|
return new ServeCommand(); |
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
$this->commands([ |
61
|
|
|
'scaffolder.command.generate', |
62
|
|
|
'scaffolder.command.cache.clear', |
63
|
|
|
'scaffolder.command.build', |
64
|
|
|
'scaffolder.command.serve' |
65
|
|
|
]); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the services provided by the provider. |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
public function provides() |
74
|
|
|
{ |
75
|
|
|
return ['scaffolder.command.generate', 'scaffolder.command.cache.clear', 'scaffolder.command.serve', 'scaffolder.command.build']; |
76
|
|
|
} |
77
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.