public function AutobanController::getBanProvidersList in Automatic IP ban (Autoban) 8
Get Ban providers list.
Parameters
string $provider_id: Ban provider ID.
Return value
array List ban providers or provider's data.
1 call to AutobanController::getBanProvidersList()
- AutobanController::getBanManagerData in src/
Controller/ AutobanController.php - Get IP Ban Manager data from provider name.
File
- src/
Controller/ AutobanController.php, line 185
Class
- AutobanController
- Provides an Autoban functional.
Namespace
Drupal\autoban\ControllerCode
public function getBanProvidersList($provider_id = NULL) {
$banProvidersList = [];
$container = \Drupal::getContainer();
$kernel = $container
->get('kernel');
// Get all services list.
$services = $kernel
->getCachedContainerDefinition()['services'];
foreach ($services as $service_id => $value) {
$service_def = unserialize($value);
if (!empty($service_def['properties']) && !empty($service_def['properties']['_serviceId'])) {
$service_id = $service_def['properties']['_serviceId'];
$aservices = explode('.', $service_id);
// Filter for services with ban_provider.
if (!empty($aservices[1]) && $aservices[1] == 'ban_provider') {
$service = $container
->get($service_id);
$id = $service
->getId();
$name = $service
->getName();
$banProvidersList[$id] = [
'name' => $name,
'service' => $service,
];
}
}
}
if (!empty($provider_id)) {
return isset($banProvidersList[$provider_id]) ? $banProvidersList[$provider_id] : NULL;
}
else {
return $banProvidersList;
}
}