YamlAclFixture::load()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 4
nop 2
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