Test Setup Failed
Pull Request — master (#190)
by
unknown
08:43
created

privilege   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 11 1
A save() 0 15 3
1
<?php
2
/**
3
 * @copyright CONTENT CONTROL GmbH, http://www.contentcontrol-berlin.de
4
 */
5
6
namespace midcom\datamanager\storage;
7
8
use midcom_error;
9
10
/**
11
 * Experimental storage class
12
 */
13
class privilege extends delayed
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function load()
19
    {
20
        //$source = $this->object->get_parameter($this->config['storage']['domain'], $this->config['storage']['name']);
21
        $source = $this->object->get_privilege(
22
                    $this->config['type_config']['privilege_name'],
23
                    $this->config['type_config']['assignee'],
24
                    $this->config['type_config']['classname']
25
                  );
26
27
        return $source->__get('value');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function save()
34
    {
35
        //workaround for weird mgd API behavior where setting falsy (i.e. deleting) a nonexistent parameter
36
        //returns an error
37
        if (  !$this->value
38
            && $this->load() === null) {
39
            return true;
40
        }
41
42
        return $this->object->set_privilege(
43
                $this->config['type_config']['privilege_name'],
44
                $this->config['type_config']['assignee'],
45
                $this->value,
46
                $this->config['type_config']['classname']);
47
    }
48
}