|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00035 class Zend_Service_StrikeIron 00036 { 00041 protected $_options; 00042 00048 public function __construct($options = array()) 00049 { 00050 $this->_options = $options; 00051 } 00052 00061 public function getService($options = array()) 00062 { 00063 $class = isset($options['class']) ? $options['class'] : 'Base'; 00064 unset($options['class']); 00065 00066 if (strpos($class, '_') === false) { 00067 $class = "Zend_Service_StrikeIron_{$class}"; 00068 } 00069 00070 try { 00071 if (!class_exists($class)) { 00072 require_once 'Zend/Loader.php'; 00073 @Zend_Loader::loadClass($class); 00074 } 00075 if (!class_exists($class, false)) { 00076 throw new Exception('Class file not found'); 00077 } 00078 } catch (Exception $e) { 00079 $msg = "Service '$class' could not be loaded: " . $e->getMessage(); 00083 require_once 'Zend/Service/StrikeIron/Exception.php'; 00084 throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e); 00085 } 00086 00087 // instantiate and return the service 00088 $service = new $class(array_merge($this->_options, $options)); 00089 return $service; 00090 } 00091 00092 }