|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Mrluke\Privileges; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use Illuminate\Support\Facades\Validator; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* ServiceProvider for package. |
|
10
|
|
|
* |
|
11
|
|
|
* @author Łukasz Sitnicki (mr-luke) |
|
12
|
|
|
* @link http://github.com/mr-luke/searcher |
|
13
|
|
|
* |
|
14
|
|
|
* @category Laravel |
|
15
|
|
|
* @package mr-luke/privileges |
|
16
|
|
|
* @license MIT |
|
17
|
|
|
*/ |
|
18
|
|
|
class PrivilegesServiceProvider extends ServiceProvider |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Perform post-registration booting of services. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function boot() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
28
|
|
|
|
|
29
|
|
|
$this->publishes([__DIR__ .'/../config/privileges.php' => config_path('privileges.php')], 'config'); |
|
30
|
|
|
|
|
31
|
|
|
$this->publishes([__DIR__.'/../database/migrations/' => database_path('migrations')], 'migrations'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Register any application services. |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
|
|
public function register() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->mergeConfigFrom(__DIR__ .'/../config/privileges.php', 'privileges'); |
|
42
|
|
|
|
|
43
|
|
|
$this->app->singleton('mrluke-privileges-detector', function ($app) { |
|
44
|
|
|
|
|
45
|
|
|
$manager = $app->make('mrluke-privileges-manager'); |
|
46
|
|
|
|
|
47
|
|
|
return new \Mrluke\Privileges\Detector($manager); |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
$this->app->singleton('mrluke-privileges-manager', function ($app) { |
|
51
|
|
|
|
|
52
|
|
|
$schema = \Mrluke\Configuration\Schema::createFromFile( |
|
53
|
|
|
__DIR__.'/../config/schema.json', |
|
54
|
|
|
true |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
$config = new \Mrluke\Configuration\Host( |
|
58
|
|
|
$app['config']->get('privileges'), |
|
59
|
|
|
$schema |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
return new \Mrluke\Privileges\Manager($config); |
|
63
|
|
|
}); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|