Completed
Push — dev ( 8eacd8...04be10 )
by De Cramer
02:44
created

Menu::onBeginRound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
4
namespace eXpansion\Bundle\Menu\Plugins;
5
use eXpansion\Bundle\Menu\Plugins\Gui\MenuFactory;
6
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
7
use eXpansion\Framework\Core\DataProviders\Listener\MatchDataListenerInterface;
8
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface;
9
use eXpansion\Framework\Core\Storage\Data\Player;
10
use Maniaplanet\DedicatedServer\Structures\Map;
11
12
13
/**
14
 * Class Menu
15
 *
16
 * @package eXpansion\Bundle\Menu\Plugins;
17
 * @author  oliver de Cramer <[email protected]>
18
 */
19
class Menu implements StatusAwarePluginInterface, MatchDataListenerInterface
20
{
21
22
    /** @var  AdminGroups */
23
    protected $adminGroups;
24
25
    /** @var MenuFactory */
26
    protected $menuGuiFactory;
27
28
    /**
29
     * Menu constructor.
30
     *
31
     * @param AdminGroups $adminGroups
32
     * @param MenuFactory $menuGuiFactory
33
     */
34
    public function __construct(AdminGroups $adminGroups, MenuFactory $menuGuiFactory)
35
    {
36
        $this->adminGroups = $adminGroups;
37
        $this->menuGuiFactory = $menuGuiFactory;
38
    }
39
40
41
    /**
42
     * Set the status of the plugin
43
     *
44
     * @param boolean $status
45
     *
46
     * @return $this
47
     */
48
    public function setStatus($status)
49
    {
50
        if ($status) {
51
            $this->displayMenu();
52
        }
53
54
        return $this;
55
    }
56
57
    /**
58
     * Display a menu for each user group
59
     */
60
    protected function displayMenu()
61
    {
62
        foreach ($this->adminGroups->getUserGroups() as $userGroup)
63
        {
64
            $this->menuGuiFactory->create($userGroup);
65
        }
66
    }
67
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function onBeginMap(Map $map)
73
    {
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79
    public function onEndMap(Map $map)
80
    {
81
    }
82
}