Public Member Functions | Protected Attributes

Zend_Loader_Autoloader_Resource Class Reference

Inheritance diagram for Zend_Loader_Autoloader_Resource:
Zend_Loader_Autoloader_Interface

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()

Detailed Description

Definition at line 35 of file Resource.php.


Constructor & Destructor Documentation

__construct ( options )

Constructor

Parameters:
array | Zend_Config$optionsConfiguration options for resource autoloader
Returns:
void

Definition at line 68 of file Resource.php.


Member Function Documentation

__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

Parameters:
string$method
array$args
Returns:
mixed
Exceptions:
Zend_Loader_Exceptionif 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

Parameters:
string$typeidentifier for the resource type being loaded
string$pathpath relative to resource base path containing the resource types
null | string$namespacesub-component namespace to append to base namespace that qualifies this resource type
Returns:
Zend_Loader_Autoloader_Resource

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', ), ));

Parameters:
array$types
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 321 of file Resource.php.

autoload ( class )

Attempt to autoload a class

Parameters:
string$class
Returns:
mixed False if not matched, otherwise result if include operation

Implements Zend_Loader_Autoloader_Interface.

Definition at line 191 of file Resource.php.

clearResourceTypes (  )

Clear all resource types

Returns:
Zend_Loader_Autoloader_Resource

Definition at line 397 of file Resource.php.

getBasePath (  )

Get base path to this set of resources

Returns:
string

Definition at line 257 of file Resource.php.

getClassPath ( class )

Helper method to calculate the correct class path

Parameters:
string$class
Returns:
False if not matched other wise the correct path

Definition at line 140 of file Resource.php.

getDefaultResourceType (  )

Get default resource type to use when calling load()

Returns:
string|null

Definition at line 423 of file Resource.php.

getNamespace (  )

Get namespace this autoloader handles

Returns:
string

Definition at line 235 of file Resource.php.

getResourceTypes (  )

Retrieve resource type mappings

Returns:
array

Definition at line 360 of file Resource.php.

hasResourceType ( type )

Is the requested resource type defined?

Parameters:
string$type
Returns:
bool

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.

Parameters:
string$resource
string$type
Returns:
object
Exceptions:
Zend_Loader_Exceptionif resource type not specified or invalid

Definition at line 440 of file Resource.php.

removeResourceType ( type )

Remove the requested resource type

Parameters:
string$type
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 382 of file Resource.php.

setBasePath ( path )

Set base path for this set of resources

Parameters:
string$path
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 246 of file Resource.php.

setDefaultResourceType ( type )

Set default resource type to use when calling load()

Parameters:
string$type
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 410 of file Resource.php.

setNamespace ( namespace )

Set namespace that this autoloader handles

Parameters:
string$namespace
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 224 of file Resource.php.

setOptions ( array $  options )

Set class state from options

Parameters:
array$options
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 206 of file Resource.php.

setResourceTypes ( array $  types )

Overwrite existing and set multiple resource types at once

See also:
Zend_Loader_Autoloader_Resource::addResourceTypes()
Parameters:
array$types
Returns:
Zend_Loader_Autoloader_Resource

Definition at line 349 of file Resource.php.


The documentation for this class was generated from the following file: