[ancestors...]] public static array $assoc = []; // [id => ['children' => [ids...]]] public static array $allIds = []; // cache for getAllLocationIds per id public static array $tree = []; // for getTree() public static array $flat = []; // for getLocations() public static function reset(): void { self::$rootChains = []; self::$assoc = []; self::$allIds = []; self::$tree = []; self::$flat = []; } public static function getLocationRootChain(int $locationid): array { return self::$rootChains[$locationid] ?? [$locationid]; } public static function getLocationsAssoc(): array { return self::$assoc; } public static function getAllLocationIds(int $startId, bool $includeZero = false): array { if ($startId === 0) { $ids = array_keys(self::$assoc); if ($includeZero) array_unshift($ids, 0); return $ids; } if (isset(self::$assoc[$startId])) { return array_merge([$startId], self::$assoc[$startId]['children'] ?? []); } return [$startId]; } public static function getTree(): array { return self::$tree; } public static function getLocations(int $start, int $depth, bool $includeSublocations, bool $assocOnly): array { return self::$flat; } }