Total Complexity | 5 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class CommentController |
||
13 | { |
||
14 | private ViewRenderer $viewRenderer; |
||
15 | |||
16 | public function __construct(ViewRenderer $viewRenderer) |
||
19 | } |
||
20 | |||
21 | public function index(Request $request, CommentService $service): Response |
||
22 | { |
||
23 | $paginator = $service->getFeedPaginator(); |
||
24 | if ($request->getAttribute('next') !== null) { |
||
25 | $paginator = $paginator->withNextPageToken((string)$request->getAttribute('next')); |
||
26 | } |
||
27 | |||
28 | if ($this->isAjaxRequest($request)) { |
||
29 | return $this->viewRenderer->renderPartial('_comments', ['data' => $paginator]); |
||
30 | } |
||
31 | |||
32 | return $this->viewRenderer->render('index', ['data' => $paginator]); |
||
33 | } |
||
34 | |||
35 | private function isAjaxRequest(Request $request): bool |
||
38 | } |
||
39 | } |
||
40 |