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

privilege::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
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
}