blob: 72ce92f472d210cfb7493ea3073bf6f7228d550d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
class OpeningTimes
{
/**
* Get opening times for given location.
* Format is the decoded JSON from DB column, i.e. currently a list of entries:
* {
* "days": ["Monday", "Tuesday", ...],
* "openingtime": "8:00",
* "closingtime": "20:00"
* }
*/
public static function forLocation(int $locationId)
{
static $openingTimesList = false;
if ($openingTimesList === false) {
$openingTimesList = Database::queryKeyValueList("SELECT locationid, openingtime FROM location
WHERE openingtime IS NOT NULL");
}
$chain = Location::getLocationRootChain($locationId);
foreach ($chain as $lid) {
if (isset($openingTimesList[$lid])) {
if (is_string($openingTimesList[$lid])) {
$openingTimesList[$lid] = json_decode($openingTimesList[$lid], true);
}
return $openingTimesList[$lid];
}
}
return null;
}
}
|