123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace ForkBB\Models\AdminList;
- use ForkBB\Models\Model as ParentModel;
- use RuntimeException;
- class Model extends ParentModel
- {
- /**
- * Загружает список id админов из кеша/БД
- */
- public function init(): Model
- {
- $this->list = $this->c->Cache->get('admins');
- if (! \is_array($this->list)) {
- $this->list = \array_flip($this->c->users->adminsIds());
- if (true !== $this->c->Cache->set('admins', $this->list)) {
- throw new RuntimeException('Unable to write value to cache - admins');
- }
- }
- return $this;
- }
- /**
- * Сбрасывает кеш списка id админов
- */
- public function reset(): Model
- {
- if (true !== $this->c->Cache->delete('admins')) {
- throw new RuntimeException('Unable to remove key from cache - admins');
- }
- return $this;
- }
- }
|