Completed
Pull Request — master (#167)
by
unknown
03:24
created

MapRatings::onApplicationInit()   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\LocalMapRatings\Plugin;
4
5
6
use eXpansion\Bundle\LocalMapRatings\DataProviders\Listener\MapRatingsDataListener;
7
use eXpansion\Bundle\LocalMapRatings\Model\Maprating;
8
use eXpansion\Bundle\LocalMapRatings\Plugin\Gui\MapRatingsWidget;
9
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceExpApplication;
10
use eXpansion\Framework\Core\Model\UserGroups\Group;
11
12
class MapRatings implements ListenerInterfaceExpApplication, MapRatingsDataListener
13
{
14
15
    /**
16
     * @var MapRatingsWidget
17
     */
18
    private $mapRatingsWidget;
19
    /**
20
     * @var Group
21
     */
22
    private $players;
23
24
    /**
25
     * MapRatings constructor.
26
     * @param MapRatingsWidget $mapRatingsWidget
27
     * @param Group            $players
28
     */
29
    public function __construct(MapRatingsWidget $mapRatingsWidget, Group $players)
30
    {
31
        $this->mapRatingsWidget = $mapRatingsWidget;
32
        $this->players = $players;
33
    }
34
35
    /**
36
     * called at eXpansion init
37
     *
38
     * @return void
39
     */
40
    public function onApplicationInit()
41
    {
42
43
    }
44
45
    /**
46
     * called when init is done and callbacks are enabled
47
     *
48
     * @return void
49
     */
50
    public function onApplicationReady()
51
    {
52
        $this->mapRatingsWidget->create($this->players);
53
    }
54
55
    /**
56
     * called when requesting application stop
57
     *
58
     * @return void
59
     */
60
    public function onApplicationStop()
61
    {
62
63
    }
64
65
    /**
66
     * Called when map ratings are loaded.
67
     *
68
     * @param Maprating[] $ratings
69
     */
70
    public function onMapRatingsLoaded($ratings)
71
    {
72
        $this->mapRatingsWidget->update($this->players);
73
    }
74
75
    /**
76
     * Called when map ratings are changed.
77
     *
78
     * @param Maprating[] $ratings
79
     */
80
    public function onMapRatingsChanged($ratings)
81
    {
82
        $this->mapRatingsWidget->update($this->players);
83
    }
84
}
85