Update pihole module
This commit is contained in:
@@ -97,10 +97,26 @@ $apiRequest = function (array $instance, array $params) use ($normalizeApiPath):
|
||||
return ['ok' => true, 'data' => $data, 'http_code' => $httpCode, 'url' => $full];
|
||||
};
|
||||
|
||||
$pickInstances = function (string $target) use ($instances): array {
|
||||
$resolvePrimaryId = function () use ($instances): ?string {
|
||||
foreach ($instances as $id => $row) {
|
||||
if (!empty($row['is_primary'])) {
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
$first = array_key_first($instances);
|
||||
return $first !== null ? (string)$first : null;
|
||||
};
|
||||
|
||||
$pickInstances = function (string $target) use ($instances, $resolvePrimaryId): array {
|
||||
if ($target === 'all') {
|
||||
return $instances;
|
||||
}
|
||||
if ($target === 'primary') {
|
||||
$primaryId = $resolvePrimaryId();
|
||||
if ($primaryId !== null && isset($instances[$primaryId])) {
|
||||
return [$primaryId => $instances[$primaryId]];
|
||||
}
|
||||
}
|
||||
if (isset($instances[$target])) {
|
||||
return [$target => $instances[$target]];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user