|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\Acme\Plugins; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\Acme\Plugins\Gui\TotoWindowFactory; |
|
6
|
|
|
use eXpansion\Bundle\Acme\Plugins\Gui\WindowFactory; |
|
7
|
|
|
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceExpApplication; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\UserGroups\Group; |
|
9
|
|
|
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface; |
|
10
|
|
|
use eXpansion\Framework\Core\Services\Console; |
|
11
|
|
|
use eXpansion\Framework\Notifications\Services\Notifications; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* TotoPlugin is a test plugin to be removed. |
|
15
|
|
|
* |
|
16
|
|
|
* @package eXpansion\Framework\Core\Plugins |
|
17
|
|
|
*/ |
|
18
|
|
|
class TotoPlugin implements ListenerInterfaceExpApplication, StatusAwarePluginInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var Console */ |
|
21
|
|
|
protected $console; |
|
22
|
|
|
|
|
23
|
|
|
/** @var TotoWindowFactory */ |
|
24
|
|
|
protected $mlFactory; |
|
25
|
|
|
|
|
26
|
|
|
/** @var Group */ |
|
27
|
|
|
protected $playersGroup; |
|
28
|
|
|
/** |
|
29
|
|
|
* @var Notifications |
|
30
|
|
|
*/ |
|
31
|
|
|
private $notifications; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* TotoPlugin constructor. |
|
35
|
|
|
* @param Group $players |
|
36
|
|
|
* @param Console $console |
|
37
|
|
|
* @param Notifications $notifications |
|
38
|
|
|
* @param TotoWindowFactory $mlFactory |
|
39
|
|
|
*/ |
|
40
|
|
|
function __construct( |
|
|
|
|
|
|
41
|
|
|
Group $players, |
|
42
|
|
|
Console $console, |
|
43
|
|
|
Notifications $notifications, |
|
44
|
|
|
TotoWindowFactory $mlFactory |
|
45
|
|
|
) { |
|
46
|
|
|
$this->console = $console; |
|
47
|
|
|
$this->playersGroup = $players; |
|
48
|
|
|
$this->notifications = $notifications; |
|
49
|
|
|
$this->mlFactory = $mlFactory; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Set the status of the plugin |
|
54
|
|
|
* |
|
55
|
|
|
* @param boolean $status |
|
56
|
|
|
* |
|
57
|
|
|
* @return null |
|
58
|
|
|
*/ |
|
59
|
|
|
public function setStatus($status) |
|
60
|
|
|
{ |
|
61
|
|
|
if ($status) { |
|
62
|
|
|
$this->mlFactory->create($this->playersGroup); |
|
63
|
|
|
} else { |
|
64
|
|
|
$this->mlFactory->destroy($this->playersGroup); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* called at eXpansion init |
|
70
|
|
|
* |
|
71
|
|
|
* @return void |
|
72
|
|
|
*/ |
|
73
|
|
|
public function onApplicationInit() |
|
74
|
|
|
{ |
|
75
|
|
|
// do nothing |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* called when init is done and callbacks are enabled |
|
80
|
|
|
* |
|
81
|
|
|
* @return void |
|
82
|
|
|
*/ |
|
83
|
|
|
public function onApplicationReady() |
|
84
|
|
|
{ |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* called when requesting application stop |
|
90
|
|
|
* |
|
91
|
|
|
* @return void |
|
92
|
|
|
*/ |
|
93
|
|
|
public function onApplicationStop() |
|
94
|
|
|
{ |
|
95
|
|
|
// do nothing |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.