ResourceFactory: Add function create(<name>)

The ConfigAwareFactory is an interface forcing "backend-type" classes to call
ResourceFactory::createResource() passing a config they got in the constructor.

That's kind of overdesigned, if the ResourceFactory wants to be something like
a service locator it's responsabilities should include object instantiation.

refs #5514
This commit is contained in:
Marius Hein 2014-08-28 11:22:02 +02:00
parent 35d11bd145
commit 9d0037a53a
1 changed files with 11 additions and 0 deletions

View File

@ -132,4 +132,15 @@ class ResourceFactory implements ConfigAwareFactory
}
return $resource;
}
/**
* Create a resource from name
*
* @param string $resourceName
* @return DbConnection|LdapConnection|LivestatusConnection|StatusdatReader
*/
public static function create($resourceName)
{
return self::createResource(self::getResourceConfig($resourceName));
}
}