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\Middleware\Items; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Error\FormResult; |
17
|
|
|
use Romm\Formz\Exceptions\EntryNotFoundException; |
18
|
|
|
use Romm\Formz\Form\FormObject; |
19
|
|
|
use Romm\Formz\Middleware\MiddlewareInterface; |
20
|
|
|
use Romm\Formz\Middleware\Signal\MiddlewareSignal; |
21
|
|
|
use Romm\Formz\Middleware\State\StateMiddlewareDependencyTrait; |
22
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\Arguments; |
23
|
|
|
use TYPO3\CMS\Extbase\Mvc\Web\Request; |
24
|
|
|
|
25
|
|
|
abstract class AbstractMiddleware implements MiddlewareInterface |
26
|
|
|
{ |
27
|
|
|
use StateMiddlewareDependencyTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param array $options |
31
|
|
|
*/ |
32
|
|
|
public function __construct(array $options = []) |
33
|
|
|
{ |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @todo |
38
|
|
|
*/ |
39
|
|
|
final public function initialize() |
40
|
|
|
{ |
41
|
|
|
// @todo add options handling |
42
|
|
|
|
43
|
|
|
$this->initializeMiddleware(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @todo |
48
|
|
|
*/ |
49
|
|
|
protected function initializeMiddleware() |
50
|
|
|
{ |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return FormObject |
55
|
|
|
*/ |
56
|
|
|
protected function getFormObject() |
57
|
|
|
{ |
58
|
|
|
return $this->state->getFormObject(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return FormResult |
63
|
|
|
*/ |
64
|
|
|
protected function getResult() |
65
|
|
|
{ |
66
|
|
|
return $this->state->getResult(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return Request |
71
|
|
|
*/ |
72
|
|
|
protected function getRequest() |
73
|
|
|
{ |
74
|
|
|
return $this->state->getRequest(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return Arguments |
79
|
|
|
*/ |
80
|
|
|
protected function getArguments() |
81
|
|
|
{ |
82
|
|
|
return $this->state->getArguments(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return int |
87
|
|
|
*/ |
88
|
|
|
public function getPriority() |
89
|
|
|
{ |
90
|
|
|
return 0; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Returns the name of the signal on which this middleware is bound. |
95
|
|
|
* |
96
|
|
|
* @return string |
97
|
|
|
* @throws EntryNotFoundException |
98
|
|
|
*/ |
99
|
|
|
final public function getBoundSignalName() |
100
|
|
|
{ |
101
|
|
|
$interfaces = class_implements($this); |
102
|
|
|
|
103
|
|
|
foreach ($interfaces as $interface) { |
104
|
|
|
if (in_array(MiddlewareSignal::class, class_implements($interface))) { |
105
|
|
|
return $interface; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
throw new EntryNotFoundException('@todo'); // @todo |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|