Skip to content

Commit

Permalink
ResourceFactory: Add function create(<name>)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mxhash committed Aug 28, 2014
1 parent 35d11bd commit 9d0037a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/Icinga/Data/ResourceFactory.php
Expand Up @@ -132,4 +132,15 @@ public static function createResource(Zend_Config $config)
}
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));
}
}

0 comments on commit 9d0037a

Please sign in to comment.