1 | <?php |
||
10 | abstract class BaseController |
||
11 | { |
||
12 | protected $logger; |
||
13 | |||
14 | protected $database; |
||
15 | |||
16 | protected $request; |
||
17 | |||
18 | protected $response; |
||
19 | |||
20 | protected $args; |
||
21 | |||
22 | /** |
||
23 | * @param Request $request |
||
24 | * @param Response $response |
||
25 | * @param array $args |
||
26 | */ |
||
27 | protected function setParams($request, $response, $args) |
||
34 | |||
35 | /** |
||
36 | * @return UserService |
||
37 | */ |
||
38 | protected function getUserService() |
||
39 | { |
||
40 | $service = new UserService($this->database); |
||
41 | |||
42 | return $service; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Send response with json as standard format. |
||
47 | * |
||
48 | * @param string $status |
||
49 | * @param mixed $message |
||
50 | * @param int $code |
||
51 | * @return array $response |
||
52 | */ |
||
53 | protected function jsonResponse($status, $message, $code) |
||
64 | |||
65 | /** |
||
66 | * Log each request. |
||
67 | */ |
||
68 | protected function logRequest() |
||
80 | |||
81 | /** |
||
82 | * Log each response. |
||
83 | * |
||
84 | * @param array $response |
||
85 | */ |
||
86 | protected function logResponse($response) |
||
94 | } |
||
95 |