|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\Core\Plugins\Gui; |
|
4
|
|
|
use eXpansion\Framework\Core\Helpers\Translations; |
|
5
|
|
|
use eXpansion\Framework\Core\Model\Gui\Manialink; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\Window; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\UserGroups\Group; |
|
9
|
|
|
use eXpansion\Framework\Core\Plugins\GuiHandler; |
|
10
|
|
|
use eXpansion\Framework\Core\Plugins\UserGroups\Factory; |
|
11
|
|
|
use FML\Controls\Control; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class ManialiveFactory allow the creation of manialinks. |
|
15
|
|
|
* |
|
16
|
|
|
* @package eXpansion\Framework\Core\Plugins\Gui |
|
17
|
|
|
* @author Oliver de Cramer |
|
18
|
|
|
*/ |
|
19
|
|
|
class WidgetFactory extends ManialinkFactory { |
|
20
|
|
|
|
|
21
|
|
|
/** @var Translations */ |
|
22
|
|
|
protected $translationsHelper; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* WidgetFactory constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param $name |
|
28
|
|
|
* @param $sizeX |
|
29
|
|
|
* @param $sizeY |
|
30
|
|
|
* @param null $posX |
|
31
|
|
|
* @param null $posY |
|
32
|
|
|
* @param GuiHandler $guiHandler |
|
33
|
|
|
* @param Factory $groupFactory |
|
34
|
|
|
* @param ActionFactory $actionFactory |
|
35
|
|
|
* @param Translations $translationsHelper |
|
36
|
|
|
* @param string $className |
|
37
|
|
|
*/ |
|
38
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
39
|
|
|
$name, |
|
40
|
|
|
$sizeX, |
|
41
|
|
|
$sizeY, |
|
42
|
|
|
$posX, |
|
43
|
|
|
$posY, |
|
44
|
|
|
GuiHandler $guiHandler, |
|
45
|
|
|
Factory $groupFactory, |
|
46
|
|
|
ActionFactory $actionFactory, |
|
47
|
|
|
Translations $translationsHelper, |
|
48
|
|
|
$className = Window::class |
|
49
|
|
|
) { |
|
50
|
|
|
// Hack for FML to use default MP alignements. |
|
51
|
|
|
Control::clearDefaultAlign(); |
|
52
|
|
|
|
|
53
|
|
|
parent::__construct( |
|
54
|
|
|
$name, |
|
55
|
|
|
$sizeX, |
|
56
|
|
|
$sizeY, |
|
57
|
|
|
$posX, |
|
58
|
|
|
$posY, |
|
59
|
|
|
$guiHandler, |
|
60
|
|
|
$groupFactory, |
|
61
|
|
|
$actionFactory, |
|
62
|
|
|
$className |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
$this->translationsHelper = $translationsHelper; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param Group $group |
|
70
|
|
|
* |
|
71
|
|
|
* @return Window |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function createManialink(Group $group) |
|
74
|
|
|
{ |
|
75
|
|
|
$className = $this->className; |
|
76
|
|
|
$manialink = new $className( |
|
77
|
|
|
$group, |
|
78
|
|
|
$this->translationsHelper, |
|
79
|
|
|
$this->name, |
|
80
|
|
|
$this->sizeX, |
|
81
|
|
|
$this->sizeY, |
|
82
|
|
|
$this->posX, |
|
83
|
|
|
$this->posY |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
return $manialink; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.