Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
paginationaction.php
1<?php
2
4
9
15final class PaginationAction implements Action
16{
17 private PageNavigation $pagination;
18 private ?PageNavigationStorage $storage;
19
25 public static function getId(): string
26 {
27 return 'pagination';
28 }
29
34 public function __construct(PageNavigation $pagination, ?PageNavigationStorage $storage)
35 {
36 $this->pagination = $pagination;
37 $this->storage = $storage;
38 }
39
49 public function processRequest(HttpRequest $request): ?Result
50 {
51 if (\Bitrix\Main\Context::getCurrent()->getRequest() !== $request)
52 {
53 trigger_error('Pagination working only request from context', E_USER_WARNING);
54 }
55
56 $tmp = clone $this->pagination;
57 $tmp->setCurrentPage(1);
58 $tmp->initFromUri();
59
60 if ($this->pagination->getCurrentPage() !== $tmp->getCurrentPage())
61 {
62 $this->pagination->setCurrentPage($tmp->getCurrentPage());
63
64 if (isset($this->storage))
65 {
66 $this->storage->save($this->pagination);
67 }
68 }
69
70 return new Result();
71 }
72}
__construct(PageNavigation $pagination, ?PageNavigationStorage $storage)