|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\MlComposeBundle\UiComponents; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\Core\Model\Gui\FmlManialink; |
|
6
|
|
|
use eXpansion\Framework\Core\Plugins\Gui\FmlManialinkFactory; |
|
7
|
|
|
use FML\Controls\Control; |
|
8
|
|
|
use FML\Controls\Frame; |
|
9
|
|
|
use oliverde8\AssociativeArraySimplified\AssociativeArray; |
|
10
|
|
|
use Oliverde8\PageCompose\Block\BlockDefinitionInterface; |
|
11
|
|
|
use Oliverde8\PageCompose\Service\UiComponents; |
|
12
|
|
|
use Oliverde8\PageCompose\UiComponent\AbstractUiComponent; |
|
13
|
|
|
use Symfony\Component\ExpressionLanguage\ExpressionLanguage; |
|
14
|
|
|
use Symfony\Component\PropertyAccess\PropertyAccess; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class BaseFmlComponent |
|
18
|
|
|
* |
|
19
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
20
|
|
|
* @copyright 2018 Oliverde8 |
|
21
|
|
|
* @package eXpansion\Framework\MlComposeBundle\UiComponents |
|
22
|
|
|
*/ |
|
23
|
|
|
class FmlComponent extends AbstractUiComponent |
|
24
|
|
|
{ |
|
25
|
|
|
public function __construct(UiComponents $uiComponents, $fmlClass) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
parent::__construct($uiComponents); |
|
28
|
|
|
$this->propertAccess = PropertyAccess::createPropertyAccessor(); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Display the component. |
|
34
|
|
|
* |
|
35
|
|
|
* @param BlockDefinitionInterface $blockDefinition |
|
36
|
|
|
* @param array ...$args |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
public function display(BlockDefinitionInterface $blockDefinition, ...$args) |
|
41
|
|
|
{ |
|
42
|
|
|
$arguments = [ |
|
43
|
|
|
'factory' => $args[0], |
|
44
|
|
|
'manialink' => $args[1], |
|
45
|
|
|
'args' => $args, |
|
46
|
|
|
]; |
|
47
|
|
|
$expressionLanguage = new ExpressionLanguage(); |
|
48
|
|
|
$configuration = new AssociativeArray($blockDefinition->getConfiguration()); |
|
49
|
|
|
$class = $configuration->get('class'); |
|
50
|
|
|
|
|
51
|
|
|
/** @var Control $component */ |
|
52
|
|
|
$component = new $class($configuration->get('id', $blockDefinition->getUniqueKey())); |
|
53
|
|
|
|
|
54
|
|
|
foreach ($blockDefinition->getSubBlocks() as $block) { |
|
55
|
|
|
/** @var Frame $component */ |
|
56
|
|
|
$component->addChild($this->uiComponents->display($block, ...$args)); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
foreach ($blockDefinition->getConfiguration() as $key => $value) { |
|
60
|
|
|
$function = ucwords("set_$key"); |
|
61
|
|
|
$component->$function($expressionLanguage->evaluate($value, $arguments)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $component; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.