|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\Menu\Gui; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\Menu\Model\Menu\ItemInterface; |
|
6
|
|
|
use eXpansion\Bundle\Menu\Model\Menu\ParentItem; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
8
|
|
|
use eXpansion\Framework\Core\Plugins\Gui\ActionFactory; |
|
9
|
|
|
use eXpansion\Framework\Gui\Ui\Factory; |
|
10
|
|
|
use FML\Controls\Label; |
|
11
|
|
|
use FML\Types\Container; |
|
12
|
|
|
use FML\Types\Renderable; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class MenuTabsFactory |
|
16
|
|
|
* |
|
17
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
18
|
|
|
* @copyright 2017 Smile |
|
19
|
|
|
* @package eXpansion\Bundle\Maps\Gui |
|
20
|
|
|
*/ |
|
21
|
|
|
class MenuTabsFactory |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var Factory */ |
|
24
|
|
|
protected $uiFactory; |
|
25
|
|
|
|
|
26
|
|
|
/** @var ActionFactory */ |
|
27
|
|
|
protected $actionFactory; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* MenuTabsFactory constructor. |
|
31
|
|
|
* |
|
32
|
|
|
* @param Factory $uiFactory |
|
33
|
|
|
* @param ActionFactory $actionFactory |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(Factory $uiFactory, ActionFactory $actionFactory) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->uiFactory = $uiFactory; |
|
38
|
|
|
$this->actionFactory = $actionFactory; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param ManialinkInterface $manialink |
|
43
|
|
|
* @param Container $tabsFrame |
|
44
|
|
|
* @param ParentItem $rootItem |
|
45
|
|
|
* @param $openId |
|
46
|
|
|
* |
|
47
|
|
|
* @return Renderable |
|
48
|
|
|
*/ |
|
49
|
|
|
public function createTabsMenu( |
|
50
|
|
|
ManialinkInterface $manialink, |
|
51
|
|
|
Container $tabsFrame, |
|
52
|
|
|
ParentItem $rootItem, |
|
53
|
|
|
$actionCallback, |
|
54
|
|
|
$openId |
|
55
|
|
|
) { |
|
56
|
|
|
|
|
57
|
|
|
$label = $this->uiFactory->createLabel("expansion_menu.menu"); |
|
58
|
|
|
$label->setPosition(0, 0); |
|
59
|
|
|
$label->setSize(30, 5); |
|
60
|
|
|
$label->setTextSize(4); |
|
61
|
|
|
$label->setTextColor('FFFFFF'); |
|
62
|
|
|
$label->setHorizontalAlign("center"); |
|
63
|
|
|
$label->setTranslate(true); |
|
64
|
|
|
$tabsFrame->addChild($label); |
|
65
|
|
|
|
|
66
|
|
|
$posX = 28; |
|
67
|
|
|
foreach ($rootItem->getChilds() as $item) { |
|
68
|
|
|
if ($rootItem->isVisibleFor($manialink->getUserGroup())) { |
|
|
|
|
|
|
69
|
|
|
$action = $this->actionFactory->createManialinkAction( |
|
70
|
|
|
$manialink, |
|
71
|
|
|
$actionCallback, |
|
72
|
|
|
['item' => $item, 'ml' => $manialink] |
|
73
|
|
|
); |
|
74
|
|
|
$label = $this->uiFactory->createLabel($item->getLabelId()); |
|
75
|
|
|
|
|
76
|
|
|
$label->setPosition($posX, 0); |
|
77
|
|
|
$label->setSize(24, 5); |
|
78
|
|
|
$label->setAction($action); |
|
79
|
|
|
$label->setTextSize(3); |
|
80
|
|
|
$label->setTextColor('FFFFFF'); |
|
81
|
|
|
$label->setHorizontalAlign(Label::CENTER); |
|
82
|
|
|
$label->setTranslate(true); |
|
83
|
|
|
|
|
84
|
|
|
if ($item->getId() == $openId) { |
|
85
|
|
|
$underline = $this->uiFactory->createLine($posX - 13, -5); |
|
86
|
|
|
$underline->to($posX + 13, -5); |
|
87
|
|
|
$underline->setColor('FFFFFF'); |
|
88
|
|
|
$tabsFrame->addChild($underline); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
$tabsFrame->addChild($label); |
|
92
|
|
|
$posX += 26; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return $tabsFrame; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: