Model.php 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace ForkBB\Models\AdminList;
  3. use ForkBB\Models\Model as ParentModel;
  4. class Model extends ParentModel
  5. {
  6. /**
  7. * Загружает список id админов из кеша/БД
  8. *
  9. * @return AdminList\Model
  10. */
  11. public function init(): self
  12. {
  13. if ($this->c->Cache->has('admins')) {
  14. $this->list = $this->c->Cache->get('admins');
  15. } else {
  16. $this->list = \array_flip($this->c->users->adminsIds());
  17. $this->c->Cache->set('admins', $this->list);
  18. }
  19. return $this;
  20. }
  21. /**
  22. * Сбрасывает кеш списка id админов
  23. *
  24. * @return AdminList\Model
  25. */
  26. public function reset(): self
  27. {
  28. $this->c->Cache->delete('admins');
  29. return $this;
  30. }
  31. }