1 | <?php |
||
15 | class StreamController extends Controller |
||
16 | { |
||
17 | /** |
||
18 | * default provider. |
||
19 | */ |
||
20 | const DEFAULT_SOURCE = 'debril.provider.default'; |
||
21 | |||
22 | /** |
||
23 | * parameter used to force refresh at every hit (skips 'If-Modified-Since' usage). |
||
24 | * set it to true for debug purpose. |
||
25 | */ |
||
26 | const FORCE_PARAM_NAME = 'force_refresh'; |
||
27 | |||
28 | /** |
||
29 | * @var \DateTime |
||
30 | */ |
||
31 | protected $since; |
||
32 | |||
33 | /** |
||
34 | * @param Request $request |
||
35 | * |
||
36 | * @return Response |
||
37 | */ |
||
38 | 3 | public function indexAction(Request $request) |
|
50 | |||
51 | /** |
||
52 | * Extract the 'If-Modified-Since' value from the headers. |
||
53 | * |
||
54 | * @return \DateTime |
||
55 | */ |
||
56 | 3 | protected function getModifiedSince() |
|
64 | |||
65 | /** |
||
66 | * @param Request $request |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | 3 | protected function setModifiedSince(Request $request) |
|
82 | |||
83 | /** |
||
84 | * Generate the HTTP response |
||
85 | * 200 : a full body containing the stream |
||
86 | * 304 : Not modified. |
||
87 | * |
||
88 | * @param array $options |
||
89 | * @param $format |
||
90 | * @param string $source |
||
91 | * |
||
92 | * @return Response |
||
93 | * |
||
94 | * @throws \Exception |
||
95 | */ |
||
96 | 3 | protected function createStreamResponse(array $options, $format, $source = self::DEFAULT_SOURCE) |
|
112 | |||
113 | /** |
||
114 | * @param Response $response |
||
115 | * @param FeedInterface $feed |
||
116 | * @return $this |
||
117 | */ |
||
118 | 1 | protected function setFeedHeaders(Response $response, FeedInterface $feed) |
|
130 | |||
131 | /** |
||
132 | * Get the Stream's content using a FeedContentProviderInterface |
||
133 | * The FeedContentProviderInterface instance is provided as a service |
||
134 | * default : debril.provider.service. |
||
135 | * |
||
136 | * @param array $options |
||
137 | * @param string $source |
||
138 | * |
||
139 | * @return FeedInterface |
||
140 | * |
||
141 | * @throws \Exception |
||
142 | */ |
||
143 | 3 | protected function getContent(array $options, $source) |
|
157 | |||
158 | /** |
||
159 | * Returns true if the controller must ignore the last modified date. |
||
160 | * |
||
161 | * @return bool |
||
162 | */ |
||
163 | 1 | protected function mustForceRefresh() |
|
171 | |||
172 | /** |
||
173 | * @return boolean true if the feed must be private |
||
174 | */ |
||
175 | 1 | protected function isPrivate() |
|
179 | |||
180 | /** |
||
181 | * @return \FeedIo\FeedIo |
||
182 | */ |
||
183 | 1 | protected function getFeedIo() |
|
187 | |||
188 | } |
||
189 |