Cleanup service providers
This commit is contained in:
@@ -16,25 +16,12 @@ use Illuminate\Support\ServiceProvider;
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
* Register the service provider.
|
||||
*
|
||||
* This service provider is a great spot to register your various container
|
||||
* bindings with the application. As you can see, we are registering our
|
||||
* "Registrar" implementation here. You can add your own bindings too!
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar',
|
||||
'CachetHQ\Cachet\Services\Registrar'
|
||||
);
|
||||
$this->app->bind('Illuminate\Contracts\Auth\Registrar', 'CachetHQ\Cachet\Services\Registrar');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,23 @@ use Illuminate\Support\ServiceProvider;
|
||||
class BusServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
* Boot the service provider.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function ($command) {
|
||||
return Dispatcher::simpleMapping(
|
||||
$command, 'CachetHQ\Cachet\Commands', 'CachetHQ\Cachet\Handlers\Commands'
|
||||
);
|
||||
return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Commands', 'CachetHQ\Cachet\Handlers\Commands');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
36
app/Providers/ComposerServiceProvider.php
Normal file
36
app/Providers/ComposerServiceProvider.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Composers\DashboardComposer;
|
||||
use CachetHQ\Cachet\Composers\IndexComposer;
|
||||
use CachetHQ\Cachet\Composers\LoggedUserComposer;
|
||||
use CachetHQ\Cachet\Composers\TimezoneLocaleComposer;
|
||||
use CachetHQ\Cachet\Composers\ThemeComposer;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ComposerServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->view->composer('*', LoggedUserComposer::class);
|
||||
$this->app->view->composer('index', IndexComposer::class);
|
||||
$this->app->view->composer('index', ThemeComposer::class);
|
||||
$this->app->view->composer('dashboard.*', DashboardComposer::class);
|
||||
$this->app->view->composer(['setup', 'dashboard.settings.app-setup'], TimezoneLocaleComposer::class);
|
||||
}
|
||||
}
|
||||
@@ -11,21 +11,68 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Config\Repository;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||
use Exception;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConfigServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Overwrite any vendor / package configuration.
|
||||
* Boot the service provider.
|
||||
*
|
||||
* This service provider is intended to provide a convenient location for you
|
||||
* to overwrite any "vendor" or package configuration that you may want to
|
||||
* modify before the application handles the incoming request / command.
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
try {
|
||||
// Get app custom configuration.
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
|
||||
// Set the Segment.com settings.
|
||||
if (Setting::get('app_track')) {
|
||||
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
|
||||
$this->app->config->set('segment.write_key', $segmentRepository->fetch());
|
||||
}
|
||||
|
||||
// Setup Cors.
|
||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||
$allowedOrigins[] = Setting::get('app_domain');
|
||||
|
||||
// Add our allowed domains too.
|
||||
if ($allowedDomains = Setting::get('allowed_domains')) {
|
||||
$domains = explode(',', $allowedDomains);
|
||||
foreach ($domains as $domain) {
|
||||
$allowedOrigins[] = $domain;
|
||||
}
|
||||
} else {
|
||||
$allowedOrigins[] = env('APP_URL');
|
||||
}
|
||||
|
||||
$this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
|
||||
} catch (Exception $e) {
|
||||
// Don't throw any errors, we may not be setup yet.
|
||||
}
|
||||
|
||||
// Override default app values.
|
||||
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
||||
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
|
||||
|
||||
// Set custom lang.
|
||||
$this->app->translator->setLocale($appLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
config([
|
||||
//
|
||||
]);
|
||||
$this->app->bindShared('setting', function () {
|
||||
return new Repository(new SettingModel());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,10 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConsoleServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
@@ -26,16 +26,4 @@ class EventServiceProvider extends ServiceProvider
|
||||
'EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
{
|
||||
parent::boot($events);
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use Exception;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LoadConfigServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$appDomain = $appLocale = null;
|
||||
|
||||
try {
|
||||
// Get app custom configuration.
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
|
||||
// Set the Segment.com settings.
|
||||
if (Setting::get('app_track')) {
|
||||
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
|
||||
$this->app->config->set('segment.write_key', $segmentRepository->fetch());
|
||||
}
|
||||
|
||||
// Setup Cors.
|
||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||
$allowedOrigins[] = Setting::get('app_domain');
|
||||
|
||||
// Add our allowed domains too.
|
||||
if ($allowedDomains = Setting::get('allowed_domains')) {
|
||||
$domains = explode(',', $allowedDomains);
|
||||
foreach ($domains as $domain) {
|
||||
$allowedOrigins[] = $domain;
|
||||
}
|
||||
} else {
|
||||
$allowedOrigins[] = env('APP_URL');
|
||||
}
|
||||
|
||||
$this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
|
||||
} catch (Exception $e) {
|
||||
// Don't throw any errors, we may not be setup yet.
|
||||
}
|
||||
|
||||
// Override default app values.
|
||||
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
||||
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
|
||||
|
||||
// Set custom lang.
|
||||
$this->app->translator->setLocale($appLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,10 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class RepositoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
@@ -26,9 +26,11 @@ class RouteServiceProvider extends ServiceProvider
|
||||
protected $namespace = 'CachetHQ\Cachet\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
* Define the route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
@@ -39,6 +41,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register model bindings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerBindings()
|
||||
{
|
||||
@@ -56,6 +60,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
|
||||
@@ -16,18 +16,12 @@ use CachetHQ\Cachet\Segment\HttpRepository;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class SegmentApiServiceProvider extends ServiceProvider
|
||||
class SegmentServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Config\Repository;
|
||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class SettingsServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bindShared('setting', function () {
|
||||
return new Repository(new SettingModel());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Cachet HQ <support@cachethq.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ViewComposerServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the service provider.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
|
||||
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
|
||||
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\ThemeComposer');
|
||||
$this->app->view->composer('dashboard.*', 'CachetHQ\Cachet\Composers\DashboardComposer');
|
||||
$this->app->view->composer([
|
||||
'setup',
|
||||
'dashboard.settings.app-setup',
|
||||
], 'CachetHQ\Cachet\Composers\TimezoneLocaleComposer');
|
||||
}
|
||||
}
|
||||
@@ -165,15 +165,13 @@ return [
|
||||
*/
|
||||
'CachetHQ\Cachet\Providers\AppServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\BusServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ComposerServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ConfigServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ConsoleServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\EventServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RepositoryServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RouteServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SettingsServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SegmentApiServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ViewComposerServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\LoadConfigServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SegmentServiceProvider',
|
||||
'CachetHQ\Segment\SegmentServiceProvider',
|
||||
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user