setOptions($options); } } public function setOptions(Array $options) { foreach ($options as $optionName => $optionValue) { $setMethod = 'set' . $optionName; if (method_exists($this, $setMethod)) { $this->{$setMethod}($optionValue); } } } /** * setRegistry() - required by the enabled interface to get an instance of * the registry * * @param Zend_Tool_Framework_Registry_Interface $registry * @return Zend_Tool_Framework_Loader_Abstract */ public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry) { $this->_registry = $registry; return $this; } /** * @param array $classesToLoad * @return Zend_Tool_Framework_Loader_Abstract */ public function setClassesToLoad(array $classesToLoad) { $this->_classesToLoad = $classesToLoad; return $this; } public function load() { $manifestRegistry = $this->_registry->getManifestRepository(); $providerRegistry = $this->_registry->getProviderRepository(); $loadedClasses = array(); // loop through the loaded classes and ensure that foreach ($this->_classesToLoad as $class) { if (!class_exists($class)) { Zend_Loader::loadClass($class); } // reflect class to see if its something we want to load $reflectionClass = new ReflectionClass($class); if ($this->_isManifestImplementation($reflectionClass)) { $manifestRegistry->addManifest($reflectionClass->newInstance()); $loadedClasses[] = $class; } if ($this->_isProviderImplementation($reflectionClass)) { $providerRegistry->addProvider($reflectionClass->newInstance()); $loadedClasses[] = $class; } } return $loadedClasses; } /** * @param ReflectionClass $reflectionClass * @return bool */ private function _isManifestImplementation($reflectionClass) { return ( $reflectionClass->implementsInterface('Zend_Tool_Framework_Manifest_Interface') && !$reflectionClass->isAbstract() ); } /** * @param ReflectionClass $reflectionClass * @return bool */ private function _isProviderImplementation($reflectionClass) { $providerRegistry = $this->_registry->getProviderRepository(); return ( $reflectionClass->implementsInterface('Zend_Tool_Framework_Provider_Interface') && !$reflectionClass->isAbstract() && !$providerRegistry->hasProvider($reflectionClass->getName(), false) ); } }