1 | <?php |
||
2 | |||
3 | /** |
||
4 | * AppInterface.php |
||
5 | * |
||
6 | * The Jaxon app functions. |
||
7 | * |
||
8 | * @package jaxon-core |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
9 | * @author Thierry Feuzeu <[email protected]> |
||
10 | * @copyright 2022 Thierry Feuzeu <[email protected]> |
||
11 | * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
||
12 | * @link https://github.com/jaxon-php/jaxon-core |
||
13 | */ |
||
0 ignored issues
–
show
|
|||
14 | |||
15 | namespace Jaxon\App; |
||
16 | |||
17 | use Jaxon\Plugin\Package; |
||
18 | use Jaxon\Plugin\ResponsePlugin; |
||
19 | use Jaxon\Request\Factory\Factory; |
||
20 | use Jaxon\Request\Factory\RequestFactory; |
||
21 | use Jaxon\Request\Handler\CallbackManager; |
||
22 | use Jaxon\Response\ResponseInterface; |
||
23 | use Jaxon\Utils\Http\UriException; |
||
24 | use Psr\Container\ContainerInterface; |
||
25 | use Psr\Log\LoggerInterface; |
||
26 | use Closure; |
||
27 | |||
28 | interface AppInterface |
||
0 ignored issues
–
show
|
|||
29 | { |
||
30 | /** |
||
31 | * Set the logger. |
||
32 | * |
||
33 | * @param LoggerInterface $logger |
||
0 ignored issues
–
show
|
|||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function setLogger(LoggerInterface $logger); |
||
0 ignored issues
–
show
|
|||
38 | |||
39 | /** |
||
40 | * Set the value of a config option |
||
41 | * |
||
42 | * @param string $sName The option name |
||
0 ignored issues
–
show
|
|||
43 | * @param mixed $sValue The option value |
||
0 ignored issues
–
show
|
|||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function setOption(string $sName, $sValue); |
||
0 ignored issues
–
show
|
|||
48 | |||
49 | /** |
||
50 | * Get the value of a config option |
||
51 | * |
||
52 | * @param string $sName The option name |
||
0 ignored issues
–
show
|
|||
53 | * @param mixed|null $xDefault The default value, to be returned if the option is not defined |
||
0 ignored issues
–
show
|
|||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | public function getOption(string $sName, $xDefault = null); |
||
0 ignored issues
–
show
|
|||
58 | |||
59 | /** |
||
60 | * Check the presence of a config option |
||
61 | * |
||
62 | * @param string $sName The option name |
||
0 ignored issues
–
show
|
|||
63 | * |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function hasOption(string $sName): bool; |
||
0 ignored issues
–
show
|
|||
67 | |||
68 | /** |
||
69 | * Get the configured character encoding |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getCharacterEncoding(): string; |
||
0 ignored issues
–
show
|
|||
74 | |||
75 | /** |
||
76 | * Get the content type of the HTTP response |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getContentType(): string; |
||
0 ignored issues
–
show
|
|||
81 | |||
82 | /** |
||
83 | * @return Factory |
||
84 | */ |
||
85 | public function factory(): Factory; |
||
0 ignored issues
–
show
|
|||
86 | |||
87 | /** |
||
88 | * Get a request to a registered class |
||
89 | * |
||
90 | * @param string $sClassName The class name |
||
91 | * |
||
92 | * @return RequestFactory|null |
||
93 | */ |
||
94 | public function request(string $sClassName = ''): ?RequestFactory; |
||
0 ignored issues
–
show
|
|||
95 | |||
96 | /** |
||
97 | * Get the HTML tags to include Jaxon javascript files into the page. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getJs(): string; |
||
0 ignored issues
–
show
|
|||
102 | |||
103 | /** |
||
104 | * Get the HTML tags to include Jaxon javascript files into the page. |
||
105 | * |
||
106 | * @return string the javascript code |
||
107 | */ |
||
108 | public function js(): string; |
||
0 ignored issues
–
show
|
|||
109 | |||
110 | /** |
||
111 | * Get the HTML tags to include Jaxon CSS code and files into the page. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getCss(): string; |
||
0 ignored issues
–
show
|
|||
116 | |||
117 | /** |
||
118 | * Get the HTML tags to include Jaxon CSS code and files into the page. |
||
119 | * |
||
120 | * @return string the javascript code |
||
121 | */ |
||
122 | public function css(): string; |
||
0 ignored issues
–
show
|
|||
123 | |||
124 | /** |
||
125 | * Returns the js header and wrapper code to be printed into the page |
||
126 | * |
||
127 | * The javascript code returned by this function is dependent on the plugins |
||
128 | * that are included and the functions and classes that are registered. |
||
129 | * |
||
130 | * @param bool $bIncludeJs Also get the JS files |
||
0 ignored issues
–
show
|
|||
131 | * @param bool $bIncludeCss Also get the CSS files |
||
0 ignored issues
–
show
|
|||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | public function getScript(bool $bIncludeJs = false, bool $bIncludeCss = false): string; |
||
0 ignored issues
–
show
|
|||
136 | |||
137 | /** |
||
138 | * Returns the js header and wrapper code to be printed into the page |
||
139 | * |
||
140 | * @param bool $bIncludeJs Also get the JS files |
||
0 ignored issues
–
show
|
|||
141 | * @param bool $bIncludeCss Also get the CSS files |
||
0 ignored issues
–
show
|
|||
142 | * |
||
143 | * @return string the javascript code |
||
144 | * @throws UriException |
||
145 | */ |
||
146 | public function script(bool $bIncludeJs = false, bool $bIncludeCss = false): string; |
||
0 ignored issues
–
show
|
|||
147 | |||
148 | /** |
||
149 | * Determine if a call is a jaxon request or a page load request |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function canProcessRequest(): bool; |
||
0 ignored issues
–
show
|
|||
154 | |||
155 | /** |
||
156 | * Process an incoming Jaxon request, and return the response. |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | public function processRequest(); |
||
0 ignored issues
–
show
|
|||
161 | |||
162 | /** |
||
163 | * Get the Jaxon ajax response |
||
164 | * |
||
165 | * @return ResponseInterface |
||
166 | */ |
||
167 | public function ajaxResponse(): ResponseInterface; |
||
0 ignored issues
–
show
|
|||
168 | |||
169 | /** |
||
170 | * Get the HTTP response |
||
171 | * |
||
172 | * @param string $sCode The HTTP response code |
||
0 ignored issues
–
show
|
|||
173 | * |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function httpResponse(string $sCode = '200'); |
||
0 ignored issues
–
show
|
|||
177 | |||
178 | /** |
||
179 | * Get a registered response plugin |
||
180 | * |
||
181 | * @param string $sName The name of the plugin |
||
0 ignored issues
–
show
|
|||
182 | * |
||
183 | * @return ResponsePlugin|null |
||
184 | */ |
||
185 | public function plugin(string $sName): ?ResponsePlugin; |
||
0 ignored issues
–
show
|
|||
186 | |||
187 | /** |
||
188 | * Get a package instance |
||
189 | * |
||
190 | * @param string $sClassName The package class name |
||
0 ignored issues
–
show
|
|||
191 | * |
||
192 | * @return Package|null |
||
193 | */ |
||
194 | public function package(string $sClassName): ?Package; |
||
0 ignored issues
–
show
|
|||
195 | |||
196 | /** |
||
197 | * @return CallbackManager |
||
198 | */ |
||
199 | public function callback(): CallbackManager; |
||
0 ignored issues
–
show
|
|||
200 | |||
201 | /** |
||
202 | * @param Closure $xClosure A closure to create the session manager instance |
||
0 ignored issues
–
show
|
|||
203 | * |
||
204 | * @return void |
||
205 | */ |
||
206 | public function setSessionManager(Closure $xClosure); |
||
0 ignored issues
–
show
|
|||
207 | |||
208 | /** |
||
209 | * Set the container provided by the integrated framework |
||
210 | * |
||
211 | * @param ContainerInterface $xContainer The container implementation |
||
0 ignored issues
–
show
|
|||
212 | * |
||
213 | * @return void |
||
214 | */ |
||
215 | public function setContainer(ContainerInterface $xContainer); |
||
0 ignored issues
–
show
|
|||
216 | |||
217 | /** |
||
218 | * Add a view renderer with an id |
||
219 | * |
||
220 | * @param string $sRenderer The renderer name |
||
0 ignored issues
–
show
|
|||
221 | * @param string $sExtension The extension to append to template names |
||
0 ignored issues
–
show
|
|||
222 | * @param Closure $xClosure A closure to create the view instance |
||
0 ignored issues
–
show
|
|||
223 | * |
||
224 | * @return void |
||
225 | */ |
||
226 | public function addViewRenderer(string $sRenderer, string $sExtension, Closure $xClosure); |
||
0 ignored issues
–
show
|
|||
227 | |||
228 | /** |
||
229 | * Set the javascript asset |
||
230 | * |
||
231 | * @param bool $bExport Whether to export the js code in a file |
||
0 ignored issues
–
show
|
|||
232 | * @param bool $bMinify Whether to minify the exported js file |
||
0 ignored issues
–
show
|
|||
233 | * @param string $sUri The URI to access the js file |
||
234 | * @param string $sDir The directory where to create the js file |
||
235 | * |
||
236 | * @return void |
||
237 | */ |
||
238 | public function asset(bool $bExport, bool $bMinify, string $sUri = '', string $sDir = ''); |
||
0 ignored issues
–
show
|
|||
239 | |||
240 | /** |
||
241 | * Read config options from a config file and set up the library |
||
242 | * |
||
243 | * @param string $sConfigFile The full path to the config file |
||
0 ignored issues
–
show
|
|||
244 | * |
||
245 | * @return void |
||
246 | */ |
||
247 | public function setup(string $sConfigFile); |
||
0 ignored issues
–
show
|
|||
248 | } |
||
249 |