diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Tool/Framework/Loader/Abstract.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Tool/Framework/Loader/Abstract.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,156 @@ +_registry = $registry; + return $this; + } + + /** + * load() - called by the client initialize routine to load files + * + */ + public function load() + { + $this->_retrievedFiles = $this->getRetrievedFiles(); + $this->_loadedClasses = array(); + + $manifestRepository = $this->_registry->getManifestRepository(); + $providerRepository = $this->_registry->getProviderRepository(); + + $loadedClasses = array(); + + // loop through files and find the classes declared by loading the file + foreach ($this->_retrievedFiles as $file) { + if(is_dir($file)) { + continue; + } + + $classesLoadedBefore = get_declared_classes(); + $oldLevel = error_reporting(E_ALL | ~E_STRICT); // remove strict so that other packages wont throw warnings + // should we lint the files here? i think so + include_once $file; + error_reporting($oldLevel); // restore old error level + $classesLoadedAfter = get_declared_classes(); + $loadedClasses = array_merge($loadedClasses, array_diff($classesLoadedAfter, $classesLoadedBefore)); + } + + // loop through the loaded classes and ensure that + foreach ($loadedClasses as $loadedClass) { + + // reflect class to see if its something we want to load + $reflectionClass = new ReflectionClass($loadedClass); + if ($reflectionClass->implementsInterface('Zend_Tool_Framework_Manifest_Interface') + && !$reflectionClass->isAbstract()) + { + $manifestRepository->addManifest($reflectionClass->newInstance()); + $this->_loadedClasses[] = $loadedClass; + } + + if ($reflectionClass->implementsInterface('Zend_Tool_Framework_Provider_Interface') + && !$reflectionClass->isAbstract() + && !$providerRepository->hasProvider($reflectionClass->getName(), false)) + { + $providerRepository->addProvider($reflectionClass->newInstance()); + $this->_loadedClasses[] = $loadedClass; + } + + } + + return $this->_loadedClasses; + } + + /** + * getRetrievedFiles() + * + * @return array Array of Files Retrieved + */ + public function getRetrievedFiles() + { + if ($this->_retrievedFiles == null) { + $this->_retrievedFiles = $this->_getFiles(); + } + + return $this->_retrievedFiles; + } + + /** + * getLoadedClasses() + * + * @return array Array of Loaded Classes + */ + public function getLoadedClasses() + { + return $this->_loadedClasses; + } + + +}