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

WidgetFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 5
cp 0
rs 9.2
c 0
b 0
f 0
cc 1
eloc 16
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
    /**
27
     * WidgetFactory constructor.
28
     *
29
     * @param                      $name
30
     * @param                      $sizeX
31
     * @param                      $sizeY
32
     * @param null                 $posX
33
     * @param null                 $posY
34
     * @param WidgetFactoryContext $context
35
     */
36
    public function __construct(
37
        $name,
38
        $sizeX,
39
        $sizeY,
40
        $posX,
41
        $posY,
42
        WidgetFactoryContext $context
43
    ) {
44
        // Hack for FML to use default MP alignements.
45
        Control::clearDefaultAlign();
46
47
        parent::__construct(
48
            $name,
49
            $sizeX,
50
            $sizeY,
51
            $posX,
52
            $posY,
53
            $context
54
        );
55
56
        $this->translationsHelper = $context->getTranslationsHelper();
57
    }
58
59
    /**
60
     * @param Group $group
61
     *
62
     * @return Window
63
     */
64
    protected function createManialink(Group $group)
65
    {
66
67
        $className = $this->className;
68
        $manialink = new $className(
69
            $group,
70
            $this->translationsHelper,
71
            $this->name,
72
            $this->sizeX,
73
            $this->sizeY,
74
            $this->posX,
75
            $this->posY
76
        );
77
78
        return $manialink;
79
    }
80
81
82
}
83