ZendAclServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace Spekkionu\ZendAcl;
3
4
use Illuminate\Support\ServiceProvider;
5
use Laminas\Permissions\Acl\Acl;
6
use Illuminate\Contracts\Foundation\Application;
7
8
class ZendAclServiceProvider extends ServiceProvider
9
{
10
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = false;
17
18
    /**
19
     * Bootstrap the application events.
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        $this->publishes([
26
            dirname(dirname(__DIR__)) . '/config/zendacl.php' => config_path('zendacl.php'),
27
            dirname(dirname(__DIR__)) . '/config/acl.php' => base_path('routes/acl.php'),
28
            dirname(dirname(__DIR__)) . '/views' => base_path('resources/views/vendor/zendacl'),
29
        ]);
30
31
        $this->loadViewsFrom(dirname(dirname(__DIR__)).'/views', 'zendacl');
32
    }
33
34
    /**
35
     * Register the service provider.
36
     *
37
     * @return void
38
     */
39
    public function register()
40
    {
41
        $this->mergeConfigFrom(
42
            dirname(dirname(__DIR__)) . '/config/zendacl.php',
43
            'zendacl'
44
        );
45
46
        $this->app->singleton('acl', function (Application $app) {
47
            $acl = new Acl;
48
            if (file_exists(base_path('routes/acl.php'))) {
49
                include base_path('routes/acl.php');
50
            } elseif (file_exists(app_path('Http/acl.php'))) {
51
                include app_path('Http/acl.php');
52
            }
53
            return $acl;
54
        });
55
56
        $this->app->singleton('Laminas\Permissions\Acl\Acl', function (Application $app) {
57
            return $app->make('acl');
58
        });
59
    }
60
61
    /**
62
     * Get the services provided by the provider.
63
     *
64
     * @return array
65
     */
66
    public function provides()
67
    {
68
        return array('acl', 'Laminas\Permissions\Acl\Acl');
69
    }
70
}
71