AclFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
dl 0
loc 43
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 36 1
1
<?php
2
/**
3
 * @package EBloodBank
4
 * @since   1.5
5
 */
6
namespace EBloodBank;
7
8
use Psr\Container\ContainerInterface;
9
10
/**
11
 * @since 1.5
12
 */
13
class AclFactory
14
{
15
    /**
16
     * @param ContainerInterface $container
17
     * @return \EBloodBank\Acl
18
     * @since 1.5
19
     */
20
    public function __invoke(ContainerInterface $container)
21
    {
22
        $acl = new Acl();
23
24
        /* Resources */
25
        $acl->addResource('User');
26
        $acl->addResource('Donor');
27
        $acl->addResource('City');
28
        $acl->addResource('District');
29
        $acl->addResource('Setting');
30
31
        /* Roles */
32
        $acl->addRole('subscriber');
33
        $acl->allow('subscriber', 'Donor', ['read']);
34
        $acl->allow('subscriber', 'City', ['read']);
35
        $acl->allow('subscriber', 'District', ['read']);
36
37
        $acl->addRole('contributor');
38
        $acl->allow('contributor', 'Donor', ['read', 'add', 'edit', 'delete']);
39
        $acl->allow('contributor', 'City', ['read']);
40
        $acl->allow('contributor', 'District', ['read']);
41
42
        $acl->addRole('editor');
43
        $acl->allow('editor', 'User', ['read']);
44
        $acl->allow('editor', 'Donor', ['read', 'approve', 'add', 'edit', 'edit_others', 'delete', 'delete_others']);
45
        $acl->allow('editor', 'City', ['read', 'add', 'edit', 'delete']);
46
        $acl->allow('editor', 'District', ['read', 'add', 'edit', 'delete']);
47
48
        $acl->addRole('administrator');
49
        $acl->allow('administrator', 'User', ['read', 'activate', 'add', 'edit', 'delete']);
50
        $acl->allow('administrator', 'Donor', ['read', 'approve', 'add', 'edit', 'edit_others', 'delete', 'delete_others']);
51
        $acl->allow('administrator', 'City', ['read', 'add', 'edit', 'delete']);
52
        $acl->allow('administrator', 'District', ['read', 'add', 'edit', 'delete']);
53
        $acl->allow('administrator', 'Setting', ['edit']);
54
55
        return $acl;
56
    }
57
}
58