ZendAclServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 63
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 10 1
A register() 0 21 3
A provides() 0 4 1
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