46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Dipper\FlashMessage;
|
|
|
|
use Illuminate\Container\Container;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Laravel\Lumen\Application as LumenApplication;
|
|
use Illuminate\Foundation\Application as LaravelApplication;
|
|
|
|
class FlashMessageServiceProvider extends ServiceProvider
|
|
{
|
|
protected $defer = true;
|
|
|
|
public function register()
|
|
{
|
|
$this->app->singleton('flashmessage', function (Container $app) {
|
|
return new Messager($app['config']['flashmessage']);
|
|
});
|
|
|
|
$this->app->alias('flashmessage', Messager::class);
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
$configSource = __DIR__.'/../config/flashmessage.php';
|
|
|
|
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
|
|
$this->publishes([$configSource => config_path('flashmessage.php')]);
|
|
} elseif ($this->app instanceof LumenApplication) {
|
|
$this->app->configure('flashmessage');
|
|
}
|
|
$this->mergeConfigFrom($configSource, 'flashmessage');
|
|
|
|
$this->publishes([
|
|
realpath(__DIR__.'/../resources/views') => $this->app->basePath('resources/views/vendor/flashmessage'),
|
|
], 'view');
|
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'flashmessage');
|
|
}
|
|
|
|
public function provides()
|
|
{
|
|
return ['flashmessage'];
|
|
}
|
|
}
|