Properties

$_basePath

$_basePath : string

Type

string — Base path to resource classes

$_components

$_components : array

Type

array — Components handled within this resource

$_defaultResourceType

$_defaultResourceType : string

Type

string — Default resource/component to use when using object registry

$_namespace

$_namespace : string

Type

string — Namespace of classes within this resource

$_resourceTypes

$_resourceTypes : array

Type

array — Available resource types handled by this resource autoloader

Methods

__construct()

__construct(array|\Zend_Config  $options) : void

Constructor

Parameters

array|\Zend_Config $options

Configuration options for resource autoloader

__call()

__call(string  $method, array  $args) : mixed

Overloading: methods

Allow retrieving concrete resource object instances using 'get()' syntax. Example: $loader = new Zend_Loader_AutoloaderResource(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

Throws

\Zend_Loader_Exception

if method not beginning with 'get' or not matching a valid resource type is called

Returns

mixed

autoload()

autoload(string  $class) : mixed

Attempt to autoload a class

Parameters

string $class

Returns

mixed —

False if not matched, otherwise result if include operation

setOptions()

setOptions(array  $options) : \Zend_Loader_Autoloader_Resource

Set class state from options

Parameters

array $options

Returns

\Zend_Loader_Autoloader_Resource

setNamespace()

setNamespace(string  $namespace) : \Zend_Loader_Autoloader_Resource

Set namespace that this autoloader handles

Parameters

string $namespace

Returns

\Zend_Loader_Autoloader_Resource

getNamespace()

getNamespace() : string

Get namespace this autoloader handles

Returns

string

setBasePath()

setBasePath(string  $path) : \Zend_Loader_Autoloader_Resource

Set base path for this set of resources

Parameters

string $path

Returns

\Zend_Loader_Autoloader_Resource

getBasePath()

getBasePath() : string

Get base path to this set of resources

Returns

string

addResourceType()

addResourceType(string  $type, string  $path, null|string  $namespace = null) : \Zend_Loader_Autoloader_Resource

Add resource type

Parameters

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

Returns

\Zend_Loader_Autoloader_Resource

addResourceTypes()

addResourceTypes(array  $types) : \Zend_Loader_Autoloader_Resource

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

setResourceTypes()

setResourceTypes(array  $types) : \Zend_Loader_Autoloader_Resource

Overwrite existing and set multiple resource types at once

Parameters

array $types

Returns

\Zend_Loader_Autoloader_Resource

getResourceTypes()

getResourceTypes() : array

Retrieve resource type mappings

Returns

array

hasResourceType()

hasResourceType(string  $type) : boolean

Is the requested resource type defined?

Parameters

string $type

Returns

boolean

removeResourceType()

removeResourceType(string  $type) : \Zend_Loader_Autoloader_Resource

Remove the requested resource type

Parameters

string $type

Returns

\Zend_Loader_Autoloader_Resource

setDefaultResourceType()

setDefaultResourceType(string  $type) : \Zend_Loader_Autoloader_Resource

Set default resource type to use when calling load()

Parameters

string $type

Returns

\Zend_Loader_Autoloader_Resource

getDefaultResourceType()

getDefaultResourceType() : string|null

Get default resource type to use when calling load()

Returns

string|null

load()

load(string  $resource, string  $type = null) : object

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

Throws

\Zend_Loader_Exception

if resource type not specified or invalid

Returns

object