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\Processor; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Condition\ConditionTree; |
17
|
|
|
use Romm\Formz\Condition\Parser\ConditionParserFactory; |
18
|
|
|
use Romm\Formz\Configuration\Form\Field\Field; |
19
|
|
|
use Romm\Formz\Configuration\Form\Field\Validation\Validation; |
20
|
|
|
use Romm\Formz\Configuration\Form\Form; |
21
|
|
|
use Romm\Formz\Form\FormObject; |
22
|
|
|
|
23
|
|
|
class ConditionProcessor |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var FormObject |
27
|
|
|
*/ |
28
|
|
|
private $formObject; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var Form |
32
|
|
|
*/ |
33
|
|
|
private $formConfiguration; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param FormObject $formObject |
37
|
|
|
*/ |
38
|
|
|
public function __construct(FormObject $formObject) |
39
|
|
|
{ |
40
|
|
|
$this->formObject = $formObject; |
41
|
|
|
$this->formConfiguration = $this->formObject->getConfiguration();; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @todo |
46
|
|
|
* |
47
|
|
|
* @param Field $field |
48
|
|
|
* @return ConditionTree |
49
|
|
|
*/ |
50
|
|
|
public function getActivationConditionTreeForField(Field $field) |
51
|
|
|
{ |
52
|
|
|
return ConditionParserFactory::get($this->formObject) |
53
|
|
|
->parse($field->getActivation()) |
54
|
|
|
->attachConditionProcessor($this); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @todo |
59
|
|
|
* |
60
|
|
|
* @param Validation $validation |
61
|
|
|
* @return ConditionTree |
62
|
|
|
*/ |
63
|
|
|
public function getActivationConditionTreeForValidation(Validation $validation) |
64
|
|
|
{ |
65
|
|
|
return ConditionParserFactory::get($this->formObject) |
66
|
|
|
->parse($validation->getActivation()) |
67
|
|
|
->attachConditionProcessor($this); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return FormObject |
72
|
|
|
*/ |
73
|
|
|
public function getFormObject() |
74
|
|
|
{ |
75
|
|
|
return $this->formObject; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|