1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebTheory\Saveyour\Controllers; |
4
|
|
|
|
5
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
6
|
|
|
use WebTheory\Saveyour\Contracts\DataTransformerInterface; |
7
|
|
|
use WebTheory\Saveyour\Contracts\FieldDataManagerInterface; |
8
|
|
|
use WebTheory\Saveyour\Contracts\FieldOperationCacheInterface; |
9
|
|
|
use WebTheory\Saveyour\Contracts\FormFieldControllerInterface; |
10
|
|
|
use WebTheory\Saveyour\Contracts\FormFieldInterface; |
11
|
|
|
|
12
|
|
|
abstract class AbstractField implements FormFieldControllerInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var FormFieldControllerInterface |
16
|
|
|
*/ |
17
|
|
|
protected $controller; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $requestVar; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
*/ |
27
|
|
|
public function __construct(string $requestVar) |
28
|
|
|
{ |
29
|
|
|
$this->requestVar = $requestVar; |
30
|
|
|
$this->controller = $this->createFormFieldController(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the value of requestVar |
35
|
|
|
* |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
public function getRequestVar(): string |
39
|
|
|
{ |
40
|
|
|
return $this->requestVar; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* |
45
|
|
|
*/ |
46
|
|
|
public function getPresetValue(ServerRequestInterface $request) |
47
|
|
|
{ |
48
|
|
|
return $this->controller->getPresetValue($request); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* |
53
|
|
|
*/ |
54
|
|
|
public function canProcessInput(): bool |
55
|
|
|
{ |
56
|
|
|
return $this->controller->canProcessInput(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* |
61
|
|
|
*/ |
62
|
|
|
public function render(ServerRequestInterface $request): ?FormFieldInterface |
63
|
|
|
{ |
64
|
|
|
return $this->controller->render($request); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* |
69
|
|
|
*/ |
70
|
|
|
public function process(ServerRequestInterface $request): FieldOperationCacheInterface |
71
|
|
|
{ |
72
|
|
|
return $this->controller->process($request); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* |
77
|
|
|
*/ |
78
|
|
|
protected function createFormFieldController(): FormFieldControllerInterface |
79
|
|
|
{ |
80
|
|
|
return new BaseFormFieldController( |
81
|
|
|
$this->getRequestVar(), |
82
|
|
|
$this->createFormField(), |
|
|
|
|
83
|
|
|
$this->createDataManager(), |
|
|
|
|
84
|
|
|
$this->createDataTransformer(), |
|
|
|
|
85
|
|
|
$this->defineFilters(), |
|
|
|
|
86
|
|
|
$this->defineRules() |
|
|
|
|
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
*/ |
93
|
|
|
protected function createFormField(): ?FormFieldInterface |
94
|
|
|
{ |
95
|
|
|
return null; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* |
100
|
|
|
*/ |
101
|
|
|
public function createDataManager(): ?FieldDataManagerInterface |
102
|
|
|
{ |
103
|
|
|
return null; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* |
108
|
|
|
*/ |
109
|
|
|
protected function createDataTransformer(): ?DataTransformerInterface |
110
|
|
|
{ |
111
|
|
|
return null; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* |
116
|
|
|
*/ |
117
|
|
|
protected function defineFilters(): ?array |
118
|
|
|
{ |
119
|
|
|
return null; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* |
124
|
|
|
*/ |
125
|
|
|
protected function defineRules(): ?array |
126
|
|
|
{ |
127
|
|
|
return null; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
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.