|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Scabbia2 LightStack Component |
|
4
|
|
|
* https://github.com/eserozvataf/scabbia2 |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* @link https://github.com/eserozvataf/scabbia2-lightstack for the canonical source repository |
|
10
|
|
|
* @copyright 2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/) |
|
11
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0 |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Scabbia\LightStack; |
|
15
|
|
|
|
|
16
|
|
|
use Scabbia\LightStack\MiddlewareInterface; |
|
17
|
|
|
use Scabbia\LightStack\Request; |
|
18
|
|
|
use Scabbia\LightStack\RequestInterface; |
|
19
|
|
|
use Scabbia\LightStack\ResponseInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Default methods needed for implementation of an application |
|
23
|
|
|
* |
|
24
|
|
|
* @package Scabbia\LightStack |
|
25
|
|
|
* @author Eser Ozvataf <[email protected]> |
|
26
|
|
|
* @since 2.0.0 |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract class ApplicationBase implements MiddlewareInterface |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* Generates a request object |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $uMethod method |
|
34
|
|
|
* @param string $uPathInfo pathinfo |
|
35
|
|
|
* @param array|null $uDetails available keys: get, post, files, server, session, cookies, headers |
|
36
|
|
|
* |
|
37
|
|
|
* @return RequestInterface request object |
|
38
|
|
|
*/ |
|
39
|
|
|
public function generateRequest($uMethod, $uPathInfo, array $uDetails = null) |
|
40
|
|
|
{ |
|
41
|
|
|
return new Request($uMethod, $uPathInfo, $uDetails); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Generates a request object from globals |
|
46
|
|
|
* |
|
47
|
|
|
* @return RequestInterface request object |
|
48
|
|
|
*/ |
|
49
|
|
|
public function generateRequestFromGlobals() |
|
50
|
|
|
{ |
|
51
|
|
|
return Request::generateFromGlobals(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Handles a request |
|
56
|
|
|
* |
|
57
|
|
|
* @param RequestInterface $uRequest request object |
|
58
|
|
|
* @param bool $uIsSubRequest whether is a sub-request or not |
|
59
|
|
|
* |
|
60
|
|
|
* @return ResponseInterface response object |
|
61
|
|
|
*/ |
|
62
|
|
|
abstract public function handleRequest(RequestInterface $uRequest, $uIsSubRequest); |
|
63
|
|
|
} |
|
64
|
|
|
|