--- /usr/local/lib/php/Zend/Loader/Autoloader/Resource.php 2010-01-06 03:05:09.000000000 +0100 +++ ../library/Zend/Loader/Autoloader/Resource.php 2010-03-07 16:42:19.000000000 +0100 @@ -60,6 +60,11 @@ protected $_resourceTypes = array(); /** + * @var array Resource types that need to be loaded and instantiated with FQN + */ + protected $_namespacedResourceTypes = array(); + + /** * Constructor * * @param array|Zend_Config $options Configuration options for resource autoloader @@ -280,15 +285,21 @@ $this->_resourceTypes[$type] = array( 'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace, ); + // Check for heading namespace separator + if ('\\' == substr($namespace, 0, 1)) { + // Remove namespace separator + $this->_resourceTypes[$type]['namespace'] = str_replace('\\', '', $this->_resourceTypes[$type]['namespace']); + $this->_namespacedResourceTypes[$type] = true; + } } if (!is_string($path)) { require_once 'Zend/Loader/Exception.php'; throw new Zend_Loader_Exception('Invalid path specification provided; must be string'); } $this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/'); - $component = $this->_resourceTypes[$type]['namespace']; $this->_components[$component] = $this->_resourceTypes[$type]['path']; + return $this; } @@ -453,7 +464,14 @@ $namespace = $this->_resourceTypes[$type]['namespace']; $class = $namespace . '_' . ucfirst($resource); if (!isset($this->_resources[$class])) { - $this->_resources[$class] = new $class; + // Handle namespaced resource + if (isset($this->_namespacedResourceTypes[$type])) { + // Always use fully qualified name + $fullyQualifiedName = '\\' . str_replace('_', '\\', $class); + $this->_resources[$class] = new $fullyQualifiedName; + } else { + $this->_resources[$class] = new $class; + } } return $this->_resources[$class]; }