YamlAclFixture   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createObject() 0 4 1
B load() 0 16 5
A getMask() 0 4 1
1
<?php
2
3
namespace Khepin\YamlFixturesBundle\Fixture;
4
5
class YamlAclFixture extends AbstractFixture
6
{
7
    public function load($acl_manager, $tags = null)
8
    {
9
        if (!$this->hasTag($tags) || !isset($this->file['acl'])) {
10
            return;
11
        }
12
13
        foreach ($this->file['acl'] as $reference => $permissions) {
14
            foreach ($permissions as $user => $permission) {
15
                $acl_manager->setObjectPermission(
16
                    $this->loader->getReference($reference),
17
                    $this->getMask($permission),
18
                    $this->loader->getReference($user)
19
                );
20
            }
21
        }
22
    }
23
24
    /**
25
     * Retrieves the constant value for the given mask name
26
     * @param  type $permission
27
     * @return type
28
     */
29
    public function getMask($permission)
30
    {
31
        return constant('Symfony\Component\Security\Acl\Permission\MaskBuilder::'.$permission);
32
    }
33
34
    public function createObject($class, $data, $metadata, $options = array())
35
    {
36
        // No implementation for ACL fixtures
37
    }
38
}
39