1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-11-13 16:00:08 +00:00
Tims-Chat/files/lib/data/room/RoomCache.class.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.3 KiB
PHP
Raw Normal View History

2018-08-16 22:30:59 +00:00
<?php
2022-03-04 17:10:24 +00:00
2018-08-16 22:30:59 +00:00
/*
2022-03-04 17:10:24 +00:00
* Copyright (c) 2010-2022 Tim Düsterhus.
2018-08-16 22:30:59 +00:00
*
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
2022-03-10 17:56:18 +00:00
* Change Date: 2026-03-10
2018-08-16 22:30:59 +00:00
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
* or later of the General Public License.
*/
namespace chat\data\room;
2022-03-04 17:10:24 +00:00
use chat\system\cache\builder\RoomCacheBuilder;
use wcf\system\SingletonFactory;
2018-08-16 22:30:59 +00:00
/**
* Manages the room cache.
*/
2022-03-04 18:35:42 +00:00
final class RoomCache extends SingletonFactory
2022-03-04 17:10:24 +00:00
{
/**
* List of cached rooms.
*
* @var Room[]
*/
protected $rooms = [ ];
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* Cached user counts for the rooms.
*
* @var int[]
*/
protected $userCount = [ ];
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* @inheritDoc
*/
protected function init()
{
$this->rooms = RoomCacheBuilder::getInstance()->getData();
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* Returns a specific room.
*/
2022-03-04 18:12:37 +00:00
public function getRoom(int $roomID): ?Room
2022-03-04 17:10:24 +00:00
{
if (isset($this->rooms[$roomID])) {
return $this->rooms[$roomID];
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
return null;
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* Returns all rooms.
*
* @return Room[]
*/
public function getRooms()
{
return $this->rooms;
}
2018-08-16 22:30:59 +00:00
}