Completed
Pull Request — master (#99)
by De Cramer
02:42
created

WidgetFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 23
rs 9.0856
ccs 0
cts 6
cp 0
cc 1
eloc 17
nc 1
nop 6
crap 2
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\Widget;
8
use eXpansion\Framework\Core\Model\Gui\WidgetFactoryContext;
9
use eXpansion\Framework\Core\Model\Gui\Window;
10
use eXpansion\Framework\Core\Model\UserGroups\Group;
11
use eXpansion\Framework\Core\Plugins\GuiHandler;
12
use eXpansion\Framework\Core\Plugins\UserGroups\Factory;
13
use FML\Controls\Control;
14
15
/**
16
 * Class ManialiveFactory allow the creation of manialinks.
17
 *
18
 * @package eXpansion\Framework\Core\Plugins\Gui
19
 * @author Oliver de Cramer
20
 */
21
class WidgetFactory extends ManialinkFactory {
22
23
    /** @var Translations */
24
    protected $translationsHelper;
25
26
    /** @var \eXpansion\Framework\Gui\Ui\Factory  */
27
    protected $uiFactory;
28
29
    /**
30
     * WidgetFactory constructor.
31
     *
32
     * @param                      $name
33
     * @param                      $sizeX
34
     * @param                      $sizeY
35
     * @param null                 $posX
36
     * @param null                 $posY
37
     * @param WidgetFactoryContext $context
38
     */
39
    public function __construct(
40
        $name,
41
        $sizeX,
42
        $sizeY,
43
        $posX,
44
        $posY,
45
        WidgetFactoryContext $context
46
    ) {
47
        // Hack for FML to use default MP alignements.
48
        Control::clearDefaultAlign();
49
50
        parent::__construct(
51
            $name,
52
            $sizeX,
53
            $sizeY,
54
            $posX,
55
            $posY,
56
            $context
57
        );
58
59
        $this->translationsHelper = $context->getTranslationsHelper();
60
        $this->uiFactory = $context->getUiFactory();
61
    }
62
63
    /**
64
     * @param Group $group
65
     *
66
     * @return Window
67
     */
68
    protected function createManialink(Group $group)
69
    {
70
71
        $className = $this->className;
72
        $manialink = new $className(
73
            $group,
74
            $this->translationsHelper,
75
            $this->name,
76
            $this->sizeX,
77
            $this->sizeY,
78
            $this->posX,
79
            $this->posY
80
        );
81
82
        return $manialink;
83
    }
84
85
86
}
87