Public Member Functions | |
__construct ($options) | |
__call ($method, $args) | |
getClassPath ($class) | |
autoload ($class) | |
setOptions (array $options) | |
setNamespace ($namespace) | |
getNamespace () | |
setBasePath ($path) | |
getBasePath () | |
addResourceType ($type, $path, $namespace=null) | |
addResourceTypes (array $types) | |
setResourceTypes (array $types) | |
getResourceTypes () | |
hasResourceType ($type) | |
removeResourceType ($type) | |
clearResourceTypes () | |
setDefaultResourceType ($type) | |
getDefaultResourceType () | |
load ($resource, $type=null) | |
Protected Attributes | |
$_basePath | |
$_components = array() | |
$_defaultResourceType | |
$_namespace | |
$_resourceTypes = array() |
Definition at line 35 of file Resource.php.
__construct | ( | $ | options ) |
Constructor
array | Zend_Config | $options | Configuration options for resource autoloader |
Definition at line 68 of file Resource.php.
__call | ( | $ | method, |
$ | args | ||
) |
Overloading: methods
Allow retrieving concrete resource object instances using 'get<Resourcename>()' syntax. Example: $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
string | $method | |
array | $args |
Zend_Loader_Exception | if method not beginning with 'get' or not matching a valid resource type is called |
Definition at line 114 of file Resource.php.
addResourceType | ( | $ | type, |
$ | path, | ||
$ | namespace = null |
||
) |
Add resource type
string | $type | identifier for the resource type being loaded |
string | $path | path relative to resource base path containing the resource types |
null | string | $namespace | sub-component namespace to append to base namespace that qualifies this resource type |
Definition at line 270 of file Resource.php.
addResourceTypes | ( | array $ | types ) |
Add multiple resources at once
$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', ), ));
array | $types |
Definition at line 321 of file Resource.php.
autoload | ( | $ | class ) |
Attempt to autoload a class
string | $class |
Implements Zend_Loader_Autoloader_Interface.
Definition at line 191 of file Resource.php.
clearResourceTypes | ( | ) |
Clear all resource types
Definition at line 397 of file Resource.php.
getBasePath | ( | ) |
getClassPath | ( | $ | class ) |
Helper method to calculate the correct class path
string | $class |
Definition at line 140 of file Resource.php.
getDefaultResourceType | ( | ) |
Get default resource type to use when calling load()
Definition at line 423 of file Resource.php.
getNamespace | ( | ) |
getResourceTypes | ( | ) |
hasResourceType | ( | $ | type ) |
Is the requested resource type defined?
string | $type |
Definition at line 371 of file Resource.php.
load | ( | $ | resource, |
$ | type = null |
||
) |
Object registry and factory
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.
string | $resource | |
string | $type |
Zend_Loader_Exception | if resource type not specified or invalid |
Definition at line 440 of file Resource.php.
removeResourceType | ( | $ | type ) |
Remove the requested resource type
string | $type |
Definition at line 382 of file Resource.php.
setBasePath | ( | $ | path ) |
Set base path for this set of resources
string | $path |
Definition at line 246 of file Resource.php.
setDefaultResourceType | ( | $ | type ) |
Set default resource type to use when calling load()
string | $type |
Definition at line 410 of file Resource.php.
setNamespace | ( | $ | namespace ) |
Set namespace that this autoloader handles
string | $namespace |
Definition at line 224 of file Resource.php.
setOptions | ( | array $ | options ) |
Set class state from options
array | $options |
Definition at line 206 of file Resource.php.
setResourceTypes | ( | array $ | types ) |
Overwrite existing and set multiple resource types at once
array | $types |
Definition at line 349 of file Resource.php.