WindowFactory::closeManialink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Plugins\Gui;
4
5
use eXpansion\Framework\Core\Model\Gui\Factory\WindowFrameFactory;
6
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
7
use eXpansion\Framework\Core\Model\Gui\Window;
8
use eXpansion\Framework\Core\Model\Gui\WindowFactoryContext;
9
use eXpansion\Framework\Core\Model\UserGroups\Group;
10
11
/**
12
 * Class ManialiveFactory allow the creation of manialinks.
13
 *
14
 * @package eXpansion\Framework\Core\Plugins\Gui
15
 * @author Oliver de Cramer
16
 */
17
class WindowFactory extends FmlManialinkFactory
18
{
19
20
    /** @var WindowFrameFactory */
21
    protected $windowFrameFactory;
22
23
    /**
24
     * WindowFactory constructor.
25
     *
26
     * @param                      $name
27
     * @param                      $sizeX
28
     * @param                      $sizeY
29
     * @param null                 $posX
30
     * @param null                 $posY
31
     * @param WindowFactoryContext $context
32
     */
33 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
34
        $name,
35
        $sizeX,
36
        $sizeY,
37
        $posX = null,
38
        $posY = null,
39
        WindowFactoryContext $context
40
    ) {
41
        parent::__construct(
42
            $name,
43
            $sizeX,
44
            $sizeY,
45
            $posX,
46
            $posY,
47
            $context
48
        );
49
50
        $this->translationsHelper = $context->getTranslationsHelper();
51
        $this->uiFactory = $context->getUiFactory();
52
        $this->windowFrameFactory = $context->getWindowFrameFactory();
53
    }
54
55
    /**
56
     * @param Group $group
57
     *
58
     * @return Window
59
     */
60
    protected function createManialink(Group $group)
61
    {
62
        $className = $this->className;
63
64
        $manialink = new $className(
65
            $this,
66
            $group,
67
            $this->translationsHelper,
68
            $this->windowFrameFactory,
69
            $this->name,
70
            $this->sizeX,
71
            $this->sizeY,
72
            $this->posX,
73
            $this->posY
74
        );
75
76
        $actionId = $this->actionFactory->createManialinkAction(
77
            $manialink,
78
            [$this, 'closeManialink'],
79
            [],
80
            true
81
        );
82
83
        $manialink->setCloseAction($actionId);
84
85
        return $manialink;
86
    }
87
88
    public function closeManialink(ManialinkInterface $manialink)
89
    {
90
        $this->destroy($manialink->getUserGroup());
91
    }
92
93
    /**
94
     * @param ManialinkInterface|Window $manialink
95
     * @param bool|string               $busyStatus
96
     */
97
    public function setBusy(ManialinkInterface $manialink, $busyStatus = true)
98
    {
99
        $manialink->setBusy($busyStatus);
100
        $this->update($manialink->getUserGroup());
101
    }
102
103
104
}
105