1 | <?php |
||
22 | abstract class BaseRenderer |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Reference to the Service. |
||
27 | * |
||
28 | * @var \CakeDC\Api\Service\Service |
||
29 | */ |
||
30 | protected $_service = null; |
||
31 | |||
32 | /** |
||
33 | * Constructor |
||
34 | * |
||
35 | * @param Service $service The Service instantiating the Renderer. |
||
36 | */ |
||
37 | 140 | public function __construct(Service $service) |
|
38 | { |
||
39 | 140 | $this->_service = $service; |
|
40 | 140 | } |
|
41 | |||
42 | /** |
||
43 | * Confirms if the specified content type is acceptable for the response. |
||
44 | * |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function accept() |
||
48 | { |
||
49 | return true; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Builds the HTTP response. |
||
54 | * |
||
55 | * @param Result $result The result object returned by the Service. |
||
56 | * @return bool |
||
57 | */ |
||
58 | abstract public function response(Result $result = null); |
||
59 | |||
60 | /** |
||
61 | * Processes an exception thrown while processing the request. |
||
62 | * |
||
63 | * @param Exception $exception The exception object. |
||
64 | * @return void |
||
65 | */ |
||
66 | abstract public function error(Exception $exception); |
||
67 | |||
68 | /** |
||
69 | * Format error message. |
||
70 | * |
||
71 | * @param Exception $exception An Exception instance. |
||
72 | * @return string |
||
73 | */ |
||
74 | 11 | protected function _buildMessage(Exception $exception) |
|
83 | |||
84 | /** |
||
85 | * Returns formatted stack trace |
||
86 | * |
||
87 | * @param Exception $exception An Exception instance. |
||
88 | * @return array |
||
89 | */ |
||
90 | 9 | protected function _stackTrace(Exception $exception) |
|
107 | } |
||
108 |