40 lines
751 B
PHP
40 lines
751 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Option;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
/**
|
|
* 初始化所有singleton class 的 instance
|
|
*
|
|
* Class SingletonServiceProvider
|
|
* @package App\Providers
|
|
*/
|
|
class SingletonServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
// Services
|
|
$this->app->alias(\App\Services\SiteStateService::class, 'SiteState');
|
|
$this->app->singleton(\App\Services\SiteStateService::class, function($app){
|
|
return new \App\Services\SiteStateService;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
//
|
|
}
|
|
}
|