1 | <?php |
||
12 | trait View |
||
13 | { |
||
14 | /** |
||
15 | * @var ViewInterface |
||
16 | */ |
||
17 | protected $viewer; |
||
18 | |||
19 | /** |
||
20 | * Get server request |
||
21 | * |
||
22 | * @return ServerRequestInterface |
||
23 | */ |
||
24 | abstract public function getRequest(); |
||
25 | |||
26 | /** |
||
27 | * Get server request |
||
28 | * |
||
29 | * @return ResponseInterface |
||
30 | */ |
||
31 | abstract public function getResponse(); |
||
32 | |||
33 | /** |
||
34 | * Get response. set for controller |
||
35 | * |
||
36 | * @param ResponseInterface $response |
||
37 | */ |
||
38 | abstract public function setResponse(ResponseInterface $response); |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Get the template engine abstraction |
||
43 | * |
||
44 | * @return ViewInterface |
||
45 | */ |
||
46 | 3 | public function getViewer() |
|
54 | |||
55 | /** |
||
56 | * Get the template engine abstraction |
||
57 | * |
||
58 | * @param ViewInterface $viewer |
||
59 | */ |
||
60 | 2 | public function setViewer(ViewInterface $viewer) |
|
64 | |||
65 | |||
66 | /** |
||
67 | * Get path of the view files |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 1 | public function getViewPath() |
|
75 | |||
76 | /** |
||
77 | * View rendered template |
||
78 | * |
||
79 | * @param string $name Template name |
||
80 | * @param array $context Template context |
||
81 | */ |
||
82 | 1 | public function view($name, array $context = []) |
|
94 | } |
||
95 |
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.