1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebTheory\Saveyour\Controller\Abstracts; |
4
|
|
|
|
5
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
6
|
|
|
use WebTheory\Saveyour\Contracts\Controller\FormFieldControllerInterface; |
7
|
|
|
use WebTheory\Saveyour\Contracts\Data\FieldDataManagerInterface; |
8
|
|
|
use WebTheory\Saveyour\Contracts\Field\FormFieldInterface; |
9
|
|
|
use WebTheory\Saveyour\Contracts\Formatting\DataFormatterInterface; |
10
|
|
|
use WebTheory\Saveyour\Contracts\Report\ProcessedFieldReportInterface; |
11
|
|
|
use WebTheory\Saveyour\Contracts\Report\ValidationReportInterface; |
12
|
|
|
use WebTheory\Saveyour\Controller\FormFieldController; |
13
|
|
|
use WebTheory\Saveyour\Validation\Validator; |
14
|
|
|
|
15
|
|
|
abstract class AbstractField implements FormFieldControllerInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected string $__requestVar; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var bool |
24
|
|
|
*/ |
25
|
|
|
protected bool $__isPermittedToProcess = true; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var array<int,string> |
29
|
|
|
*/ |
30
|
|
|
protected array $__mustAwait = []; |
31
|
|
|
|
32
|
|
|
protected FormFieldControllerInterface $__coreController; |
33
|
|
|
|
34
|
12 |
|
public function __construct(string $requestVar, array $mustAwait = [], $processingEnabled = true) |
35
|
|
|
{ |
36
|
12 |
|
$this->__requestVar = $requestVar; |
37
|
12 |
|
$this->__mustAwait = $mustAwait; |
38
|
12 |
|
$this->__isPermittedToProcess = $processingEnabled; |
39
|
|
|
|
40
|
12 |
|
$this->__coreController = $this->createFormFieldController(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get the value of requestVar |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
3 |
|
public function getRequestVar(): string |
49
|
|
|
{ |
50
|
3 |
|
return $this->__coreController->getRequestVar(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getFormField(): ?FormFieldInterface |
54
|
|
|
{ |
55
|
|
|
return $this->__coreController->getFormField(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function requestVarPresent(ServerRequestInterface $request): bool |
59
|
|
|
{ |
60
|
|
|
return $this->__coreController->requestVarPresent($request); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function inspect($value): ValidationReportInterface |
64
|
|
|
{ |
65
|
|
|
return $this->__coreController->inspect($value); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function validate($value): bool |
69
|
|
|
{ |
70
|
|
|
return $this->__coreController->validate($value); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getPresetValue(ServerRequestInterface $request) |
74
|
|
|
{ |
75
|
|
|
return $this->__coreController->getPresetValue($request); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getUpdatedValue(ServerRequestInterface $request): ?array |
79
|
|
|
{ |
80
|
|
|
return $this->__coreController->getUpdatedValue($request); |
81
|
|
|
} |
82
|
|
|
|
83
|
3 |
|
public function mustAwait(): array |
84
|
|
|
{ |
85
|
3 |
|
return $this->__coreController->mustAwait(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function render(ServerRequestInterface $request): string |
89
|
|
|
{ |
90
|
|
|
return $this->__coreController->render($request); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function compose(ServerRequestInterface $request): FormFieldInterface |
94
|
|
|
{ |
95
|
|
|
return $this->__coreController->compose($request); |
96
|
|
|
} |
97
|
|
|
|
98
|
6 |
|
public function isPermittedToProcess(): bool |
99
|
|
|
{ |
100
|
6 |
|
return $this->__coreController->isPermittedToProcess(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function process(ServerRequestInterface $request): ProcessedFieldReportInterface |
104
|
|
|
{ |
105
|
|
|
return $this->__coreController->process($request); |
106
|
|
|
} |
107
|
|
|
|
108
|
12 |
|
protected function createFormFieldController(): FormFieldControllerInterface |
109
|
|
|
{ |
110
|
12 |
|
return new FormFieldController( |
111
|
12 |
|
$this->defineRequestVar(), |
112
|
12 |
|
$this->defineFormField(), |
|
|
|
|
113
|
12 |
|
$this->defineDataManager(), |
|
|
|
|
114
|
12 |
|
$this->defineValidator(), |
|
|
|
|
115
|
12 |
|
$this->defineDataFormatter(), |
|
|
|
|
116
|
12 |
|
$this->definePermissionProcessStatus(), |
117
|
12 |
|
$this->defineMustAwait(), |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
|
121
|
12 |
|
protected function defineRequestVar(): string |
122
|
|
|
{ |
123
|
12 |
|
return $this->__requestVar; |
124
|
|
|
} |
125
|
|
|
|
126
|
12 |
|
protected function defineFormField(): ?FormFieldInterface |
127
|
|
|
{ |
128
|
12 |
|
return null; |
129
|
|
|
} |
130
|
|
|
|
131
|
12 |
|
protected function defineDataManager(): ?FieldDataManagerInterface |
132
|
|
|
{ |
133
|
12 |
|
return null; |
134
|
|
|
} |
135
|
|
|
|
136
|
12 |
|
protected function defineDataFormatter(): ?DataFormatterInterface |
137
|
|
|
{ |
138
|
12 |
|
return null; |
139
|
|
|
} |
140
|
|
|
|
141
|
12 |
|
protected function defineValidator(): ?Validator |
142
|
|
|
{ |
143
|
12 |
|
return null; |
144
|
|
|
} |
145
|
|
|
|
146
|
12 |
|
protected function definePermissionProcessStatus(): ?bool |
147
|
|
|
{ |
148
|
12 |
|
return $this->__isPermittedToProcess; |
149
|
|
|
} |
150
|
|
|
|
151
|
12 |
|
protected function defineMustAwait(): ?array |
152
|
|
|
{ |
153
|
12 |
|
return $this->__mustAwait; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.