1 | <?php |
||
8 | class View |
||
9 | { |
||
10 | const DEFAULT_STATUS_CODE = 200; |
||
11 | |||
12 | private $data; |
||
13 | private $statusCode; |
||
14 | private $template; |
||
15 | private $cache; |
||
16 | private $headers; |
||
17 | |||
18 | /** |
||
19 | * @param mixed $data |
||
20 | * @param int $sharedMaxAge |
||
21 | * @param int $statusCode |
||
22 | * |
||
23 | * @return static |
||
24 | */ |
||
25 | 1 | public static function createCached($data, $sharedMaxAge, $statusCode = self::DEFAULT_STATUS_CODE) |
|
29 | |||
30 | /** |
||
31 | * @param mixed|null $data |
||
32 | * @param int $statusCode |
||
33 | * @param string|array $template |
||
34 | * @param array $cache |
||
35 | * @param array $headers |
||
36 | */ |
||
37 | 18 | public function __construct( |
|
50 | |||
51 | /** |
||
52 | * @return mixed|null |
||
53 | */ |
||
54 | 15 | public function getData() |
|
58 | |||
59 | /** |
||
60 | * @param string $key The key to use when creating array if data isn't already an array |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | 7 | public function getDataAsArray($key = 'data') |
|
78 | |||
79 | /** |
||
80 | * @return int |
||
81 | */ |
||
82 | 6 | public function getStatusCode() |
|
86 | |||
87 | /** |
||
88 | * Either the template name or an array of templates. |
||
89 | * |
||
90 | * @return string|array|null |
||
91 | */ |
||
92 | 10 | public function getTemplate() |
|
96 | |||
97 | /** |
||
98 | * Returns an array of cache options. |
||
99 | * |
||
100 | * @see Symfony\Component\HttpFoundation\Response::setCache |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | 8 | public function getCache() |
|
108 | |||
109 | /** |
||
110 | * @return array |
||
111 | */ |
||
112 | 7 | public function getHeaders() |
|
116 | } |
||
117 |