|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Platine Framework |
|
5
|
|
|
* |
|
6
|
|
|
* Platine Framework is a lightweight, high-performance, simple and elegant |
|
7
|
|
|
* PHP Web framework |
|
8
|
|
|
* |
|
9
|
|
|
* This content is released under the MIT License (MIT) |
|
10
|
|
|
* |
|
11
|
|
|
* Copyright (c) 2020 Platine Framework |
|
12
|
|
|
* |
|
13
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
15
|
|
|
* in the Software without restriction, including without limitation the rights |
|
16
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
18
|
|
|
* furnished to do so, subject to the following conditions: |
|
19
|
|
|
* |
|
20
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
21
|
|
|
* copies or substantial portions of the Software. |
|
22
|
|
|
* |
|
23
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
28
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
29
|
|
|
* SOFTWARE. |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
declare(strict_types=1); |
|
33
|
|
|
|
|
34
|
|
|
namespace Platine\Framework\Helper; |
|
35
|
|
|
|
|
36
|
|
|
use Platine\Config\Config; |
|
37
|
|
|
use Platine\Framework\Audit\Auditor; |
|
38
|
|
|
use Platine\Framework\Http\RouteHelper; |
|
39
|
|
|
use Platine\Lang\Lang; |
|
40
|
|
|
use Platine\Logger\LoggerInterface; |
|
41
|
|
|
use Platine\Pagination\Pagination; |
|
42
|
|
|
use Platine\Template\Template; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @class ActionHelper |
|
46
|
|
|
* @package Platine\Framework\Helper |
|
47
|
|
|
* @template T |
|
48
|
|
|
*/ |
|
49
|
|
|
class ActionHelper |
|
50
|
|
|
{ |
|
51
|
|
|
/** |
|
52
|
|
|
* Create new instance |
|
53
|
|
|
* @param Pagination $pagination |
|
54
|
|
|
* @param Sidebar $sidebar |
|
55
|
|
|
* @param ViewContext<T> $context |
|
56
|
|
|
* @param Template $template |
|
57
|
|
|
* @param RouteHelper $routeHelper |
|
58
|
|
|
* @param Flash $flash |
|
59
|
|
|
* @param Lang $lang |
|
60
|
|
|
* @param LoggerInterface $logger |
|
61
|
|
|
* @param Auditor $auditor |
|
62
|
|
|
* @param FileHelper<T> $fileHelper |
|
63
|
|
|
* @param Config<T> $config |
|
64
|
|
|
*/ |
|
65
|
|
|
public function __construct( |
|
66
|
|
|
protected Pagination $pagination, |
|
67
|
|
|
protected Sidebar $sidebar, |
|
68
|
|
|
protected ViewContext $context, |
|
69
|
|
|
protected Template $template, |
|
70
|
|
|
protected RouteHelper $routeHelper, |
|
71
|
|
|
protected Flash $flash, |
|
72
|
|
|
protected Lang $lang, |
|
73
|
|
|
protected LoggerInterface $logger, |
|
74
|
|
|
protected Auditor $auditor, |
|
75
|
|
|
protected FileHelper $fileHelper, |
|
76
|
|
|
protected Config $config |
|
77
|
|
|
) { |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Return the configuration instance |
|
82
|
|
|
* @return Config<T> |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getConfig(): Config |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->config; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Return the FileHelper |
|
91
|
|
|
* @return FileHelper<T> |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getFileHelper(): FileHelper |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->fileHelper; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* |
|
101
|
|
|
* @return Flash |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getFlash(): Flash |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->flash; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* |
|
110
|
|
|
* @return Lang |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getLang(): Lang |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->lang; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* |
|
119
|
|
|
* @return LoggerInterface |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getLogger(): LoggerInterface |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->logger; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* |
|
128
|
|
|
* @return Auditor |
|
129
|
|
|
*/ |
|
130
|
|
|
public function getAuditor(): Auditor |
|
131
|
|
|
{ |
|
132
|
|
|
return $this->auditor; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* |
|
137
|
|
|
* @return Pagination |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getPagination(): Pagination |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->pagination; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* |
|
146
|
|
|
* @return Sidebar |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getSidebar(): Sidebar |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->sidebar; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* |
|
155
|
|
|
* @return ViewContext<T> |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getContext(): ViewContext |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->context; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* |
|
164
|
|
|
* @return Template |
|
165
|
|
|
*/ |
|
166
|
|
|
public function getTemplate(): Template |
|
167
|
|
|
{ |
|
168
|
|
|
return $this->template; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* |
|
173
|
|
|
* @return RouteHelper |
|
174
|
|
|
*/ |
|
175
|
|
|
public function getRouteHelper(): RouteHelper |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->routeHelper; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|