Application/Module/Autoloader.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Application
- Subpackage
- Module
- Version
- $Id: Autoloader.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Application_Module_Autoloader
Resource loader for application module classes
- Parent(s)
- \Zend_Loader_Autoloader_Resource
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
- \global\Zend_Loader_Autoloader_Resource
Properties

string $_basePath = - Type
- string
- Inherited_from
- \Zend_Loader_Autoloader_Resource::$$_basePath

array $_components = array()array()Details- Type
- array
- Inherited_from
- \Zend_Loader_Autoloader_Resource::$$_components

string $_defaultResourceType = - Type
- string
- Inherited_from
- \Zend_Loader_Autoloader_Resource::$$_defaultResourceType

string $_namespace = - Type
- string
- Inherited_from
- \Zend_Loader_Autoloader_Resource::$$_namespace

array $_resourceTypes = array()array()Details- Type
- array
- Inherited_from
- \Zend_Loader_Autoloader_Resource::$$_resourceTypes
Methods

__call(string $method, array $args) : mixed
Allow retrieving concrete resource object instances using 'get
$loader = new Zend_Loader_Autoloader_Resource(array(
'namespace' => 'Stuff_',
'basePath' => '/path/to/some/stuff',
))
$loader->addResourceType('Model', 'models', 'Model');
$foo = $loader->getModel('Foo'); // get instance of Stuff_Model_Foo class
| Name | Type | Description |
|---|---|---|
| $method | string | |
| $args | array |
| Type | Description |
|---|---|
| mixed |
| Exception | Description |
|---|---|
| \Zend_Loader_Exception | if method not beginning with 'get' or not matching a valid resource type is called |

__construct(array | \Zend_Config $options) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $options | array | \Zend_Config |

addResourceType(string $type, string $path, null | string $namespace = null) : \Zend_Loader_Autoloader_Resource
| Name | Type | Description |
|---|---|---|
| $type | string | identifier for the resource type being loaded |
| $path | string | path relative to resource base path containing the resource types |
| $namespace | null | string | sub-component namespace to append to base namespace that qualifies this resource type |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

addResourceTypes(array $types) : \Zend_Loader_Autoloader_ResourceAdd multiple resources at once
Inherited from: \Zend_Loader_Autoloader_Resource::addResourceTypes()$types should be an associative array of resource type => specification pairs. Each specification should be an associative array containing minimally the 'path' key (specifying the path relative to the resource base path) and optionally the 'namespace' key (indicating the subcomponent namespace to append to the resource namespace).
As an example:
$loader->addResourceTypes(array(
'model' => array(
'path' => 'models',
'namespace' => 'Model',
),
'form' => array(
'path' => 'forms',
'namespace' => 'Form',
),
));
| Name | Type | Description |
|---|---|---|
| $types | array |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

autoload(string $class) : mixed
| Name | Type | Description |
|---|---|---|
| $class | string |
| Type | Description |
|---|---|
| mixed | False if not matched, otherwise result if include operation |

clearResourceTypes() : \Zend_Loader_Autoloader_ResourceClear all resource types
Inherited from: \Zend_Loader_Autoloader_Resource::clearResourceTypes()| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

getBasePath() : stringGet base path to this set of resources
Inherited from: \Zend_Loader_Autoloader_Resource::getBasePath()| Type | Description |
|---|---|
| string |

getClassPath(string $class) : FalseHelper method to calculate the correct class path
Inherited from: \Zend_Loader_Autoloader_Resource::getClassPath()| Name | Type | Description |
|---|---|---|
| $class | string |
| Type | Description |
|---|---|
| False | if not matched other wise the correct path |

getDefaultResourceType() : string | nullGet default resource type to use when calling load()
Inherited from: \Zend_Loader_Autoloader_Resource::getDefaultResourceType()| Type | Description |
|---|---|
| string | null |

getNamespace() : stringGet namespace this autoloader handles
Inherited from: \Zend_Loader_Autoloader_Resource::getNamespace()| Type | Description |
|---|---|
| string |

getResourceTypes() : arrayRetrieve resource type mappings
Inherited from: \Zend_Loader_Autoloader_Resource::getResourceTypes()| Type | Description |
|---|---|
| array |

hasResourceType(string $type) : boolIs the requested resource type defined?
Inherited from: \Zend_Loader_Autoloader_Resource::hasResourceType()| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| bool |

load(string $resource, string $type = null) : object
Loads the requested resource of type $type (or uses the default resource type if none provided). If the resource has been loaded previously, returns the previous instance; otherwise, instantiates it.
| Name | Type | Description |
|---|---|---|
| $resource | string | |
| $type | string |
| Type | Description |
|---|---|
| object |
| Exception | Description |
|---|---|
| \Zend_Loader_Exception | if resource type not specified or invalid |

removeResourceType(string $type) : \Zend_Loader_Autoloader_ResourceRemove the requested resource type
Inherited from: \Zend_Loader_Autoloader_Resource::removeResourceType()| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

setBasePath(string $path) : \Zend_Loader_Autoloader_ResourceSet base path for this set of resources
Inherited from: \Zend_Loader_Autoloader_Resource::setBasePath()| Name | Type | Description |
|---|---|---|
| $path | string |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

setDefaultResourceType(string $type) : \Zend_Loader_Autoloader_ResourceSet default resource type to use when calling load()
Inherited from: \Zend_Loader_Autoloader_Resource::setDefaultResourceType()| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

setNamespace(string $namespace) : \Zend_Loader_Autoloader_ResourceSet namespace that this autoloader handles
Inherited from: \Zend_Loader_Autoloader_Resource::setNamespace()| Name | Type | Description |
|---|---|---|
| $namespace | string |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

setOptions(array $options) : \Zend_Loader_Autoloader_ResourceSet class state from options
Inherited from: \Zend_Loader_Autoloader_Resource::setOptions()| Name | Type | Description |
|---|---|---|
| $options | array |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |

setResourceTypes(array $types) : \Zend_Loader_Autoloader_ResourceOverwrite existing and set multiple resource types at once
Inherited from: \Zend_Loader_Autoloader_Resource::setResourceTypes()| Name | Type | Description |
|---|---|---|
| $types | array |
| Type | Description |
|---|---|
| \Zend_Loader_Autoloader_Resource |
- See
- \global\Zend_Loader_Autoloader_Resource::addResourceTypes()