diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Application/Module/Bootstrap.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Application/Module/Bootstrap.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,128 @@ +setApplication($application); + + // Use same plugin loader as parent bootstrap + if ($application instanceof Zend_Application_Bootstrap_ResourceBootstrapper) { + $this->setPluginLoader($application->getPluginLoader()); + } + + $key = strtolower($this->getModuleName()); + if ($application->hasOption($key)) { + // Don't run via setOptions() to prevent duplicate initialization + $this->setOptions($application->getOption($key)); + } + + if ($application->hasOption('resourceloader')) { + $this->setOptions(array( + 'resourceloader' => $application->getOption('resourceloader') + )); + } + $this->initResourceLoader(); + + // ZF-6545: ensure front controller resource is loaded + if (!$this->hasPluginResource('FrontController')) { + $this->registerPluginResource('FrontController'); + } + + // ZF-6545: prevent recursive registration of modules + if ($this->hasPluginResource('modules')) { + $this->unregisterPluginResource('modules'); + } + } + + /** + * Ensure resource loader is loaded + * + * @return void + */ + public function initResourceLoader() + { + $this->getResourceLoader(); + } + + /** + * Get default application namespace + * + * Proxies to {@link getModuleName()}, and returns the current module + * name + * + * @return string + */ + public function getAppNamespace() + { + return $this->getModuleName(); + } + + /** + * Retrieve module name + * + * @return string + */ + public function getModuleName() + { + if (empty($this->_moduleName)) { + $class = get_class($this); + if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) { + $prefix = $matches[1]; + } else { + $prefix = $class; + } + $this->_moduleName = $prefix; + } + return $this->_moduleName; + } +}