diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Service/StrikeIron.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Service/StrikeIron.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,92 @@ +_options = $options; + } + + /** + * Factory method to return a preconfigured Zend_Service_StrikeIron_* + * instance. + * + * @param null|string $options Service options + * @return object Zend_Service_StrikeIron_* instance + * @throws Zend_Service_StrikeIron_Exception + */ + public function getService($options = array()) + { + $class = isset($options['class']) ? $options['class'] : 'Base'; + unset($options['class']); + + if (strpos($class, '_') === false) { + $class = "Zend_Service_StrikeIron_{$class}"; + } + + try { + if (!class_exists($class)) { + require_once 'Zend/Loader.php'; + @Zend_Loader::loadClass($class); + } + if (!class_exists($class, false)) { + throw new Exception('Class file not found'); + } + } catch (Exception $e) { + $msg = "Service '$class' could not be loaded: " . $e->getMessage(); + /** + * @see Zend_Service_StrikeIron_Exception + */ + require_once 'Zend/Service/StrikeIron/Exception.php'; + throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e); + } + + // instantiate and return the service + $service = new $class(array_merge($this->_options, $options)); + return $service; + } + +}