summaryrefslogtreecommitdiffstats
path: root/library/Icinga/Application/Modules/MenuItemContainer.php
blob: 88599e656a8bfc1f81cfcdc49ac1d50de60aa3ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */

namespace Icinga\Application\Modules;

/**
 * Container for module menu items
 */
class MenuItemContainer extends NavigationItemContainer
{
    /**
     * This menu item's children
     *
     * @var MenuItemContainer[]
     */
    protected $children;

    /**
     * Set this menu item's children
     *
     * @param   MenuItemContainer[]     $children
     *
     * @return  $this
     */
    public function setChildren(array $children)
    {
        $this->children = $children;
        return $this;
    }

    /**
     * Return this menu item's children
     *
     * @return  array
     */
    public function getChildren()
    {
        return $this->children ?: array();
    }

    /**
     * Add a new sub menu
     *
     * @param   string  $name
     * @param   array   $properties
     *
     * @return  MenuItemContainer   The newly added sub menu
     */
    public function add($name, array $properties = array())
    {
        $child = new MenuItemContainer($name, $properties);
        $this->children[] = $child;
        return $child;
    }
}