24 #require_once 'Zend/Loader/Autoloader/Interface.php'; 74 #require_once 'Zend/Loader/Exception.php'; 81 if ((
null === $namespace)
84 #require_once 'Zend/Loader/Exception.php'; 85 throw new Zend_Loader_Exception(
'Resource loader requires both a namespace and a base path for initialization');
88 if (!empty($namespace)) {
91 #require_once 'Zend/Loader/Autoloader.php'; 117 if (
'get' == substr(
$method, 0, 3)) {
120 #require_once 'Zend/Loader/Exception.php'; 124 #require_once 'Zend/Loader/Exception.php'; 131 #require_once 'Zend/Loader/Exception.php'; 143 $segments = explode(
'_',
$class);
147 if (!empty($namespaceTopLevel)) {
148 $namespace = array();
149 $topLevelSegments = count(explode(
'_', $namespaceTopLevel));
150 for (
$i = 0;
$i < $topLevelSegments;
$i++) {
151 $namespace[] = array_shift($segments);
153 $namespace = implode(
'_', $namespace);
154 if ($namespace != $namespaceTopLevel) {
160 if (count($segments) < 2) {
165 $final = array_pop($segments);
166 $component = $namespace;
169 $segment = array_shift($segments);
170 $component .= empty($component) ? $segment :
'_' . $segment;
171 if (isset($this->_components[$component])) {
172 $lastMatch = $component;
174 }
while (count($segments));
180 $final = substr(
$class, strlen($lastMatch) + 1);
181 $path = $this->_components[$lastMatch];
182 $classPath =
$path .
'/' . str_replace(
'_',
'/', $final) .
'.php';
200 if (
false !== $classPath) {
201 return include $classPath;
220 $methods = get_class_methods($this);
222 $method =
'set' . ucfirst($key);
238 $this->_namespace = rtrim((
string) $namespace,
'_');
260 $this->_basePath = (string)
$path;
285 if (!isset($this->_resourceTypes[
$type])) {
286 if (
null === $namespace) {
287 #require_once 'Zend/Loader/Exception.php'; 291 $namespace = ucfirst(trim($namespace,
'_'));
292 $this->_resourceTypes[
$type] = array(
293 'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel .
'_' . $namespace,
296 if (!is_string(
$path)) {
297 #require_once 'Zend/Loader/Exception.php'; 302 $component = $this->_resourceTypes[
$type][
'namespace'];
303 $this->_components[$component] = $this->_resourceTypes[
$type][
'path'];
335 foreach ($types as
$type => $spec) {
336 if (!is_array($spec)) {
337 #require_once 'Zend/Loader/Exception.php'; 340 if (!isset($spec[
'path'])) {
341 #require_once 'Zend/Loader/Exception.php'; 346 if (isset($spec[
'namespace'])) {
347 $namespace = $spec[
'namespace'];
385 return isset($this->_resourceTypes[
$type]);
397 $namespace = $this->_resourceTypes[
$type][
'namespace'];
398 unset($this->_components[$namespace]);
399 unset($this->_resourceTypes[
$type]);
411 $this->_resourceTypes = array();
412 $this->_components = array();
425 $this->_defaultResourceType =
$type;
454 if (
null ===
$type) {
457 #require_once 'Zend/Loader/Exception.php'; 462 #require_once 'Zend/Loader/Exception.php'; 465 $namespace = $this->_resourceTypes[
$type][
'namespace'];
467 if (!isset($this->_resources[
$class])) {
470 return $this->_resources[
$class];
setOptions(array $options)
addResourceTypes(array $types)
static isReadable($filename)
$_option $_optionId $class
removeResourceType($type)
load($resource, $type=null)
setDefaultResourceType($type)
addResourceType($type, $path, $namespace=null)
setResourceTypes(array $types)