File: D:/HostingSpaces/SBogers10/csb.komma.pro/vendor/komma/kms/src/Providers/SetupServiceProvider.php
<?php
namespace Komma\KMS\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Komma\KMS\Http\Middleware\HSTS;
use Komma\KMS\Http\Middleware\KmsAuthenticate;
use Komma\KMS\Http\Middleware\SiteSlugResolver;
class SetupServiceProvider extends ServiceProvider
{
const ROOT_PATH = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
public const PACKAGE_NAMESPACE = 'KMS';
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if( $this->app->runningInConsole()) {
$this->registerPublishing();
}
$this->registerResources();
$this->mergeConfigFrom(self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR .'app.php', 'app'); //Note! It does not copy the file. It reads and merges it with the already loaded app config.
//Register global middleware
/** @var Router $router */
$router = app(Router::class);
// $router->middleware([HSTS::class]);
$router->pushMiddlewareToGroup('kms', SiteSlugResolver::class);
// $router->aliasMiddleware('auth',KmsAuthenticate::class);
}
protected function registerPublishing()
{
//Publish config. Can be published like this "php artisan vendor:publish --tag=config --force"
$this->publishes([
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'calendar.php' => config_path('calendar.php'),
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'exception_mail.php' => config_path('exception_mail.php'),
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'hsts.php' => config_path('hsts.php'),
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'kms.php' => config_path('kms.php'),
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'languages.php' => config_path('languages.php'),
self::ROOT_PATH .'config' . DIRECTORY_SEPARATOR . 'auth.php' => config_path('auth.php'),
], 'kms-core-config');
//Publish public directory.
$this->publishes([
self::ROOT_PATH .'public' => public_path('vendor/kms'),
], 'kms-core-public');
}
protected function registerResources()
{
$this->loadViewsFrom(self::ROOT_PATH .'resources'.DIRECTORY_SEPARATOR.'views', self::PACKAGE_NAMESPACE);
$this->loadTranslationsFrom(self::ROOT_PATH .'resources'.DIRECTORY_SEPARATOR.'lang', self::PACKAGE_NAMESPACE);
$this->loadMigrationsFrom(self::ROOT_PATH . 'database' . DIRECTORY_SEPARATOR . 'migrations');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
}