Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sessionpagenavigationstorage.php
1<?php
2
4
9
11{
12 private const STORAGE_ID = 'grid-pagination-storage';
13 private SessionLocalStorage $storage;
14
15 public function __construct(?SessionLocalStorage $storage = null)
16 {
17 $this->storage =
18 $storage
19 ?? Application::getInstance()->getSessionLocalStorageManager()->get(self::STORAGE_ID)
20 ;
21 }
22
23 public function fill(PageNavigation $pagination): void
24 {
25 $data = $this->storage->get($pagination->getId());
26 if (is_array($data) && isset($data['current']))
27 {
28 $pagination->setCurrentPage((int)$data['current']);
29 }
30 }
31
32 public function save(PageNavigation $pagination): void
33 {
34 $this->storage->set(
35 $pagination->getId(),
36 [
37 'current' => $pagination->getCurrentPage(),
38 ]
39 );
40 }
41}