1 | <?php |
||
28 | class FoundationServiceProvider extends ServiceProvider |
||
29 | { |
||
30 | /** |
||
31 | * The commands to be registered. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $commands = [ |
||
36 | InstallCommand::class => 'command.cortex.foundation.install', |
||
37 | MigrateCommand::class => 'command.cortex.foundation.migrate', |
||
38 | PublishCommand::class => 'command.cortex.foundation.publish', |
||
39 | RollbackCommand::class => 'command.cortex.foundation.rollback', |
||
40 | CoreSeedCommand::class => 'command.cortex.foundation.coreseed', |
||
41 | CoreInstallCommand::class => 'command.cortex.foundation.coreinstall', |
||
42 | CoreMigrateCommand::class => 'command.cortex.foundation.coremigrate', |
||
43 | CorePublishCommand::class => 'command.cortex.foundation.corempublish', |
||
44 | CoreRollbackCommand::class => 'command.cortex.foundation.corerollback', |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * Register any application services. |
||
49 | * |
||
50 | * This service provider is a great spot to register your various container |
||
51 | * bindings with the application. As you can see, we are registering our |
||
52 | * "Registrar" implementation here. You can add your own bindings too! |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | public function register(): void |
||
57 | { |
||
58 | $this->overrideNotificationMiddleware(); |
||
59 | $this->overrideLaravelLocalization(); |
||
60 | $this->overrideUrlGenerator(); |
||
61 | $this->bindBlueprintMacro(); |
||
62 | $this->overrideRedirector(); |
||
63 | $this->bindBladeCompiler(); |
||
64 | $this->overrideLangJS(); |
||
65 | |||
66 | // Merge config |
||
67 | $this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'cortex.foundation'); |
||
68 | |||
69 | // Override datatables html builder |
||
70 | $this->app->bind(\Yajra\DataTables\Html\Builder::class, \Cortex\Foundation\Overrides\Yajra\DataTables\Html\Builder::class); |
||
|
|||
71 | |||
72 | // Register console commands |
||
73 | ! $this->app->runningInConsole() || $this->registerCommands(); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Bootstrap any application services. |
||
78 | * |
||
79 | * @return void |
||
80 | */ |
||
81 | public function boot(Router $router): void |
||
82 | { |
||
83 | // Early set application locale globaly |
||
84 | $router->pattern('locale', '[a-z]{2}'); |
||
85 | $this->app['laravellocalization']->setLocale(); |
||
86 | |||
87 | $router->model('media', Media::class); |
||
88 | |||
89 | // Load resources |
||
90 | $this->loadRoutesFrom(__DIR__.'/../../routes/web.php'); |
||
91 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/foundation'); |
||
92 | $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/foundation'); |
||
93 | ! $this->app->runningInConsole() || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
||
94 | $this->app->afterResolving('blade.compiler', function () { |
||
95 | require __DIR__.'/../../routes/menus.php'; |
||
96 | }); |
||
97 | |||
98 | // Publish Resources |
||
99 | ! $this->app->runningInConsole() || $this->publishResources(); |
||
100 | |||
101 | $this->app->booted(function () { |
||
102 | if ($this->app->routesAreCached()) { |
||
103 | require $this->app->getCachedRoutesPath(); |
||
104 | } else { |
||
105 | $this->app['router']->getRoutes()->refreshNameLookups(); |
||
106 | $this->app['router']->getRoutes()->refreshActionLookups(); |
||
107 | } |
||
108 | }); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Override notification middleware. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | protected function overrideNotificationMiddleware(): void |
||
126 | |||
127 | /** |
||
128 | * Bind blade compiler. |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | protected function bindBladeCompiler(): void |
||
146 | |||
147 | /** |
||
148 | * Override the Redirector instance. |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | protected function overrideRedirector(): void |
||
167 | |||
168 | /** |
||
169 | * Override the UrlGenerator instance. |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | protected function overrideUrlGenerator(): void |
||
203 | |||
204 | /** |
||
205 | * Get the URL generator request rebinder. |
||
206 | * |
||
207 | * @return \Closure |
||
208 | */ |
||
209 | protected function requestRebinder() |
||
215 | |||
216 | /** |
||
217 | * Override the LaravelLocalization instance. |
||
218 | * |
||
219 | * @return void |
||
220 | */ |
||
221 | protected function overrideLaravelLocalization(): void |
||
227 | |||
228 | /** |
||
229 | * Publish resources. |
||
230 | * |
||
231 | * @return void |
||
232 | */ |
||
233 | protected function publishResources(): void |
||
240 | |||
241 | /** |
||
242 | * Register console commands. |
||
243 | * |
||
244 | * @return void |
||
245 | */ |
||
246 | protected function registerCommands(): void |
||
255 | |||
256 | /** |
||
257 | * Register console commands. |
||
258 | * |
||
259 | * @return void |
||
260 | */ |
||
261 | protected function overrideLangJS(): void |
||
284 | |||
285 | /** |
||
286 | * Bind blueprint macro. |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | protected function bindBlueprintMacro(): void |
||
313 | } |
||
314 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.