mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
Add paramater type to ResourceFactory::getResourceConfigs()
This allows to filter resources by type.
This commit is contained in:
parent
8f3ee4dedf
commit
4891afd646
@ -56,15 +56,26 @@ class ResourceFactory implements ConfigAwareFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configuration of all existing resources, or get all resources of a given type.
|
||||
* Get the configuration of all existing resources, or all resources of the given type
|
||||
*
|
||||
* @return Config The configuration containing all resources
|
||||
* @param string $type Filter for resource type
|
||||
*
|
||||
* @return Config The resources configuration
|
||||
*/
|
||||
public static function getResourceConfigs()
|
||||
public static function getResourceConfigs($type = null)
|
||||
{
|
||||
self::assertResourcesExist();
|
||||
if ($type === null) {
|
||||
return self::$resources;
|
||||
}
|
||||
$resources = array();
|
||||
foreach (self::$resources as $name => $resource) {
|
||||
if ($resource->get('type') === $type) {
|
||||
$resources[$name] = $resource;
|
||||
}
|
||||
}
|
||||
return Config::fromArray($resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the existing resources are set. If not, load them from resources.ini
|
||||
|
Loading…
x
Reference in New Issue
Block a user