forked from InfyOmLabs/laravel-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfyOmGeneratorServiceProvider.php
executable file
·154 lines (129 loc) · 5.44 KB
/
InfyOmGeneratorServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
namespace InfyOm\Generator;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use InfyOm\Generator\Commands\API\APIControllerGeneratorCommand;
use InfyOm\Generator\Commands\API\APIGeneratorCommand;
use InfyOm\Generator\Commands\API\APIRequestsGeneratorCommand;
use InfyOm\Generator\Commands\API\TestsGeneratorCommand;
use InfyOm\Generator\Commands\APIScaffoldGeneratorCommand;
use InfyOm\Generator\Commands\Common\MigrationGeneratorCommand;
use InfyOm\Generator\Commands\Common\ModelGeneratorCommand;
use InfyOm\Generator\Commands\Common\RepositoryGeneratorCommand;
use InfyOm\Generator\Commands\Publish\GeneratorPublishCommand;
use InfyOm\Generator\Commands\Publish\PublishTablesCommand;
use InfyOm\Generator\Commands\Publish\PublishUserCommand;
use InfyOm\Generator\Commands\RollbackGeneratorCommand;
use InfyOm\Generator\Commands\Scaffold\ControllerGeneratorCommand;
use InfyOm\Generator\Commands\Scaffold\RequestsGeneratorCommand;
use InfyOm\Generator\Commands\Scaffold\ScaffoldGeneratorCommand;
use InfyOm\Generator\Commands\Scaffold\ViewsGeneratorCommand;
use InfyOm\Generator\Common\FileSystem;
use InfyOm\Generator\Common\GeneratorConfig;
use InfyOm\Generator\Generators\API\APIControllerGenerator;
use InfyOm\Generator\Generators\API\APIRequestGenerator;
use InfyOm\Generator\Generators\API\APIRoutesGenerator;
use InfyOm\Generator\Generators\API\APITestGenerator;
use InfyOm\Generator\Generators\FactoryGenerator;
use InfyOm\Generator\Generators\MigrationGenerator;
use InfyOm\Generator\Generators\ModelGenerator;
use InfyOm\Generator\Generators\RepositoryGenerator;
use InfyOm\Generator\Generators\RepositoryTestGenerator;
use InfyOm\Generator\Generators\Scaffold\ControllerGenerator;
use InfyOm\Generator\Generators\Scaffold\MenuGenerator;
use InfyOm\Generator\Generators\Scaffold\RequestGenerator;
use InfyOm\Generator\Generators\Scaffold\RoutesGenerator;
use InfyOm\Generator\Generators\Scaffold\ViewGenerator;
use InfyOm\Generator\Generators\SeederGenerator;
class InfyOmGeneratorServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
if ($this->app->runningInConsole()) {
$configPath = __DIR__.'/../config/laravel_generator.php';
$this->publishes([
$configPath => config_path('laravel_generator.php'),
], 'laravel-generator-config');
$this->publishes([
__DIR__.'/../views' => resource_path('views/vendor/laravel-generator'),
], 'laravel-generator-templates');
}
$this->registerCommands();
$this->loadViewsFrom(__DIR__.'/../views', 'laravel-generator');
View::composer('*', function ($view) {
$view->with(['config' => app(GeneratorConfig::class)]);
});
Blade::directive('tab', function () {
return '<?php echo infy_tab() ?>';
});
Blade::directive('tabs', function ($count) {
return "<?php echo infy_tabs($count) ?>";
});
Blade::directive('nl', function () {
return '<?php echo infy_nl() ?>';
});
Blade::directive('nls', function ($count) {
return "<?php echo infy_nls($count) ?>";
});
}
private function registerCommands()
{
if (!$this->app->runningInConsole()) {
return;
}
$this->commands([
APIScaffoldGeneratorCommand::class,
APIGeneratorCommand::class,
APIControllerGeneratorCommand::class,
APIRequestsGeneratorCommand::class,
TestsGeneratorCommand::class,
MigrationGeneratorCommand::class,
ModelGeneratorCommand::class,
RepositoryGeneratorCommand::class,
GeneratorPublishCommand::class,
PublishTablesCommand::class,
PublishUserCommand::class,
ControllerGeneratorCommand::class,
RequestsGeneratorCommand::class,
ScaffoldGeneratorCommand::class,
ViewsGeneratorCommand::class,
RollbackGeneratorCommand::class,
]);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/laravel_generator.php', 'laravel_generator');
$this->app->singleton(GeneratorConfig::class, function () {
return new GeneratorConfig();
});
$this->app->singleton(FileSystem::class, function () {
return new FileSystem();
});
$this->app->singleton(MigrationGenerator::class);
$this->app->singleton(ModelGenerator::class);
$this->app->singleton(RepositoryGenerator::class);
$this->app->singleton(APIRequestGenerator::class);
$this->app->singleton(APIControllerGenerator::class);
$this->app->singleton(APIRoutesGenerator::class);
$this->app->singleton(RequestGenerator::class);
$this->app->singleton(ControllerGenerator::class);
$this->app->singleton(ViewGenerator::class);
$this->app->singleton(RoutesGenerator::class);
$this->app->singleton(MenuGenerator::class);
$this->app->singleton(RepositoryTestGenerator::class);
$this->app->singleton(APITestGenerator::class);
$this->app->singleton(FactoryGenerator::class);
$this->app->singleton(SeederGenerator::class);
}
}