Completed
Pull Request — master (#210)
by
unknown
08:31
created

WidgetCurrentMap::onApplicationStop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\WidgetCurrentMap\Plugins;
4
5
use eXpansion\Bundle\WidgetCurrentMap\Plugins\Gui\CurrentMapWidgetFactory;
6
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceExpApplication;
7
use eXpansion\Framework\Core\Model\UserGroups\Group;
8
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface;
9
use eXpansion\Framework\Core\Storage\PlayerStorage;
10
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpLegacyMap;
11
use Maniaplanet\DedicatedServer\Connection;
12
use Maniaplanet\DedicatedServer\Structures\Map;
13
14
15
class WidgetCurrentMap implements StatusAwarePluginInterface, ListenerInterfaceMpLegacyMap
16
{
17
    /** @var Connection */
18
    protected $connection;
19
    /**
20
     * @var PlayerStorage
21
     */
22
    private $playerStorage;
23
    /**
24
     * @var CurrentMapWidgetFactory
25
     */
26
    private $widget;
27
    /**
28
     * @var Group
29
     */
30
    private $players;
31
32
    /**
33
     * Debug constructor.
34
     *
35
     * @param Connection              $connection
36
     * @param PlayerStorage           $playerStorage
37
     * @param CurrentMapWidgetFactory $widget
38
     * @param Group                   $players
39
     */
40
    public function __construct(
41
        Connection $connection,
42
        PlayerStorage $playerStorage,
43
        CurrentMapWidgetFactory $widget,
44
        Group $players
45
    ) {
46
        $this->connection = $connection;
47
        $this->playerStorage = $playerStorage;
48
        $this->widget = $widget;
49
        $this->players = $players;
50
    }
51
52
53
    public function setStatus($status)
54
    {
55
        if ($status) {
56
            $this->widget->create($this->players);
57
        } else {
58
            $this->widget->destroy($this->players);
59
        }
60
    }
61
62
    /**
63
     * @param Map $map
64
     *
65
     * @return void
66
     */
67
    public function onBeginMap(Map $map)
68
    {
69
        $this->widget->update($this->players);
70
    }
71
72
    /**
73
     * @param Map $map
74
     *
75
     * @return void
76
     */
77
    public function onEndMap(Map $map)
78
    {
79
        // TODO: Implement onEndMap() method.
80
    }
81
}
82