| 1 |
<?php |
| 2 |
|
| 3 |
namespace Intervention\HttpAuth\Laravel; |
| 4 |
|
| 5 |
use Illuminate\Support\ServiceProvider; |
| 6 |
use Intervention\HttpAuth\HttpAuth; |
| 7 |
|
| 8 |
class HttpAuthServiceProvider extends ServiceProvider |
| 9 |
{ |
| 10 |
/** |
| 11 |
* Indicates if loading of the provider is deferred. |
| 12 |
* |
| 13 |
* @var bool |
| 14 |
*/ |
| 15 |
protected $defer = false; |
| 16 |
|
| 17 |
/** |
| 18 |
* Bootstrap the application events. |
| 19 |
* |
| 20 |
* @return void |
| 21 |
*/ |
| 22 |
public function boot() |
| 23 |
{ |
| 24 |
$this->publishes([ |
| 25 |
__DIR__ . '/../config/config.php' => config_path('httpauth.php') |
| 26 |
]); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Register the service provider. |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
public function register() |
| 35 |
{ |
| 36 |
// merge default config |
| 37 |
$this->mergeConfigFrom( |
| 38 |
__DIR__ . '/../config/config.php', |
| 39 |
'httpauth' |
| 40 |
); |
| 41 |
|
| 42 |
// register singleton |
| 43 |
$this->app->singleton('httpauth', function ($app) { |
| 44 |
return HttpAuth::make($app['config']->get('httpauth')); |
| 45 |
}); |
| 46 |
|
| 47 |
// bind classname |
| 48 |
$this->app->bind('Intervention\HttpAuth\HttpAuth', function ($app) { |
| 49 |
return HttpAuth::make($app['config']->get('httpauth')); |
| 50 |
}); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Get the services provided by the provider. |
| 55 |
* |
| 56 |
* @return array |
| 57 |
*/ |
| 58 |
public function provides() |
| 59 |
{ |
| 60 |
return ['httpauth']; |
| 61 |
} |
| 62 |
} |
| 63 |
|