summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/inc/locationhooks.inc.php
blob: f6ef02dac2ef5a701cbd3f2e4a8cfc7e7c009c03 (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
<?php

class LocationHooks
{

	/**
	 * Resolve baseconfig id to locationid -- noop in this case
	 */
	public static function baseconfigLocationResolver(int $id): int
	{
		return $id;
	}

	/**
	 * Hook to get inheritance tree for all config vars
	 * @param int $id Locationid currently being edited
	 */
	public static function baseconfigInheritance(int $id): array
	{
		$locs = Location::getLocationsAssoc();
		if ($locs === false || !isset($locs[$id]))
			return [];
		BaseConfig::prepareWithOverrides([
			'locationid' => $locs[$id]['parentlocationid'] ?? 0
		]);
		return ConfigHolder::getRecursiveConfig(true);
	}

}