|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* 2017 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\Form\Definition\Middleware; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor; |
|
17
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface; |
|
18
|
|
|
use Romm\ConfigurationObject\Traits\ConfigurationObject\MagicMethodsTrait; |
|
19
|
|
|
use Romm\Formz\Middleware\Item\FormInjection\FormInjectionMiddleware; |
|
20
|
|
|
use Romm\Formz\Middleware\Item\FormValidation\FormValidationMiddleware; |
|
21
|
|
|
use Romm\Formz\Middleware\Item\Persistence\PersistenceFetchingMiddleware; |
|
22
|
|
|
use Romm\Formz\Middleware\Item\Persistence\PersistenceInjectionMiddleware; |
|
23
|
|
|
use Romm\Formz\Middleware\Item\Step\StepDispatchingMiddleware; |
|
24
|
|
|
use Romm\Formz\Middleware\Item\Step\StepFetchingMiddleware; |
|
25
|
|
|
use Romm\Formz\Middleware\MiddlewareInterface; |
|
26
|
|
|
|
|
27
|
|
|
class PresetMiddlewares implements DataPreProcessorInterface |
|
28
|
|
|
{ |
|
29
|
|
|
use MagicMethodsTrait; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var \Romm\Formz\Middleware\Item\FormInjection\FormInjectionMiddleware |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $formInjectionMiddleware; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var \Romm\Formz\Middleware\Item\FormValidation\FormValidationMiddleware |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $formValidationMiddleware; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var \Romm\Formz\Middleware\Item\Persistence\PersistenceInjectionMiddleware |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $persistenceInjectionMiddleware; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var \Romm\Formz\Middleware\Item\Persistence\PersistenceFetchingMiddleware |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $persistenceFetchingMiddleware; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var \Romm\Formz\Middleware\Item\Step\StepFetchingMiddleware |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $stepFetchingMiddleware; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var \Romm\Formz\Middleware\Item\Step\StepDispatchingMiddleware |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $stepDispatchingMiddleware; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the full list of preset middlewares. |
|
63
|
|
|
* |
|
64
|
|
|
* @return MiddlewareInterface[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getList() |
|
67
|
|
|
{ |
|
68
|
|
|
return get_object_vars($this); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Fills middlewares by default (if they are not filled in configuration). |
|
73
|
|
|
* |
|
74
|
|
|
* @param DataPreProcessor $processor |
|
75
|
|
|
*/ |
|
76
|
|
|
public static function dataPreProcessor(DataPreProcessor $processor) |
|
77
|
|
|
{ |
|
78
|
|
|
$data = $processor->getData(); |
|
79
|
|
|
|
|
80
|
|
|
foreach (array_keys(get_class_vars(self::class)) as $middleware) { |
|
81
|
|
|
if (false === isset($data[$middleware])) { |
|
82
|
|
|
$data[$middleware] = []; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
$processor->setData($data); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return FormInjectionMiddleware |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getFormInjectionMiddleware() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->formInjectionMiddleware; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return FormValidationMiddleware |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getFormValidationMiddleware() |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->formValidationMiddleware; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return PersistenceInjectionMiddleware |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getPersistenceInjectionMiddleware() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->persistenceInjectionMiddleware; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @return PersistenceFetchingMiddleware |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getPersistenceFetchingMiddleware() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->persistenceFetchingMiddleware; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return StepFetchingMiddleware |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getStepFetchingMiddleware() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->stepFetchingMiddleware; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @return StepDispatchingMiddleware |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getStepDispatchingMiddleware() |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->stepDispatchingMiddleware; |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|