Loader/Autoloader/Resource.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Loader
- Subpackage
- Autoloader
- Version
- $Id$
\Zend_Loader_Autoloader_Resource
- Implements
- Children
- \Zend_Application_Module_Autoloader
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
Properties
array $_components = array()
Components handled within this resource
array()
Details- Type
- array
string $_defaultResourceType
Default resource/component to use when using object registry
- Type
- string
Methods
__call(string $method, array $args) : mixed
Overloading: methods
$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) : void
Constructor
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config | Configuration options for resource autoloader |
addResourceType(string $type, string $path, null | string $namespace = null) : \Zend_Loader_Autoloader_Resource
Add resource type
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_Resource
Add multiple resources at once
$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
Attempt to autoload a class
Name | Type | Description |
---|---|---|
$class | string |
Type | Description |
---|---|
mixed | False if not matched, otherwise result if include operation |
clearResourceTypes() : \Zend_Loader_Autoloader_Resource
Clear all resource types
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
getClassPath(string $class) : False
Helper method to calculate the correct class path
Name | Type | Description |
---|---|---|
$class | string |
Type | Description |
---|---|
False | if not matched other wise the correct path |
getDefaultResourceType() : string | null
Get default resource type to use when calling load()
Type | Description |
---|---|
string | null |
hasResourceType(string $type) : bool
Is the requested resource type defined?
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
bool |
load(string $resource, string $type = null) : object
Object registry and factory
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_Resource
Remove the requested resource type
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
setBasePath(string $path) : \Zend_Loader_Autoloader_Resource
Set base path for this set of resources
Name | Type | Description |
---|---|---|
$path | string |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
setDefaultResourceType(string $type) : \Zend_Loader_Autoloader_Resource
Set default resource type to use when calling load()
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
setNamespace(string $namespace) : \Zend_Loader_Autoloader_Resource
Set namespace that this autoloader handles
Name | Type | Description |
---|---|---|
$namespace | string |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
setOptions(array $options) : \Zend_Loader_Autoloader_Resource
Set class state from options
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |
setResourceTypes(array $types) : \Zend_Loader_Autoloader_Resource
Overwrite existing and set multiple resource types at once
Name | Type | Description |
---|---|---|
$types | array |
Type | Description |
---|---|
\Zend_Loader_Autoloader_Resource |