Ui::createCustomButton()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
// Copyright 1999-2021. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Struct\Ui as Struct;
7
8
class Ui extends \PleskX\Api\Operator
9
{
10
    /**
11
     * @return array
12
     */
13
    public function getNavigation()
14
    {
15
        $response = $this->request('get-navigation');
16
17
        return unserialize(base64_decode($response->navigation));
18
    }
19
20
    /**
21
     * @param string $owner
22
     * @param array $properties
23
     *
24
     * @return int
25
     */
26
    public function createCustomButton($owner, $properties)
27
    {
28
        $packet = $this->_client->getPacket();
29
        $buttonNode = $packet->addChild($this->_wrapperTag)->addChild('create-custombutton');
30
        $buttonNode->addChild('owner')->addChild($owner);
31
        $propertiesNode = $buttonNode->addChild('properties');
32
33
        foreach ($properties as $name => $value) {
34
            $propertiesNode->addChild($name, $value);
35
        }
36
37
        $response = $this->_client->request($packet);
38
39
        return (int) $response->id;
40
    }
41
42
    /**
43
     * @param int $id
44
     *
45
     * @return Struct\CustomButton
46
     */
47
    public function getCustomButton($id)
48
    {
49
        $response = $this->request("get-custombutton.filter.custombutton-id=$id");
50
51
        return new Struct\CustomButton($response);
52
    }
53
54
    /**
55
     * @param int $id
56
     *
57
     * @return bool
58
     */
59
    public function deleteCustomButton($id)
60
    {
61
        return $this->_delete('custombutton-id', $id, 'delete-custombutton');
62
    }
63
}
64