1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2016 Romain CANON <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This file is part of the TYPO3 Formz project. |
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
7
|
|
|
* under the terms of the GNU General Public License, either |
8
|
|
|
* version 3 of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, see: |
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Romm\Formz\Condition\Parser\Node; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Condition\Items\ConditionItemInterface; |
17
|
|
|
use Romm\Formz\Condition\Processor\DataObject\PhpConditionDataObject; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* A condition node, which contains an instance of `ConditionItemInterface`. |
21
|
|
|
*/ |
22
|
|
|
class ConditionNode extends AbstractNode |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $conditionName; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ConditionItemInterface |
31
|
|
|
*/ |
32
|
|
|
protected $condition; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor, which needs a name for the condition and an instance of a |
36
|
|
|
* condition item. |
37
|
|
|
* |
38
|
|
|
* @param string $conditionName Name of the condition. |
39
|
|
|
* @param ConditionItemInterface $condition Instance of the condition item. |
40
|
|
|
*/ |
41
|
|
|
public function __construct($conditionName, ConditionItemInterface $condition) |
42
|
|
|
{ |
43
|
|
|
$this->conditionName = $conditionName; |
44
|
|
|
$this->condition = $condition; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritdoc |
49
|
|
|
*/ |
50
|
|
|
public function getCssResult() |
51
|
|
|
{ |
52
|
|
|
return $this->toArray($this->condition->getCssResult()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @inheritdoc |
57
|
|
|
*/ |
58
|
|
|
public function getJavaScriptResult() |
59
|
|
|
{ |
60
|
|
|
return $this->toArray($this->condition->getJavaScriptResult()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @inheritdoc |
65
|
|
|
*/ |
66
|
|
|
public function getPhpResult(PhpConditionDataObject $dataObject) |
67
|
|
|
{ |
68
|
|
|
return $this->condition->getPhpResult($dataObject); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return ConditionItemInterface |
73
|
|
|
*/ |
74
|
|
|
public function getCondition() |
75
|
|
|
{ |
76
|
|
|
return $this->condition; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|