summaryrefslogblamecommitdiffstats
path: root/modules-available/locations/inc/openingtimes.inc.php
blob: 3417a2134d9e1b855431a15cb04c8f3166df24ce (plain) (tree)



























                                                                                                                     
<?php

class OpeningTimes
{

	/**
	 * Get opening times for given location.
	 */
	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);
		$openingTimes = null;
		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;
	}
}