API Documentation

Zend/Loader/Autoloader/Resource.php

Show: inherited
Table of Contents

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 license@zend.com 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_Loader  
Subpackage
Autoloader  
Version
$Id: Resource.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Loader_Autoloader_Resource

Package: Zend\Loader\Autoloader

Resource loader

Implements
\Zend_Loader_Autoloader_Interface
Children
\Zend_Application_Module_Autoloader
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Used_by
\Zend_Application_Module_Bootstrap  
Used_by
\Zend_Application_Module_Autoloader  
Uses
\Zend_Loader_Autoloader_Interface  

Properties

Propertyprotectedstring  $_basePath= ''

Base path to resource classes
Details
Type
string
Propertyprotectedarray  $_components= 'array()'

Components handled within this resource
Default valuearray()Details
Type
array
Propertyprotectedstring  $_defaultResourceType= ''

Default resource/component to use when using object registry
Details
Type
string
Propertyprotectedstring  $_namespace= ''

Namespace of classes within this resource
Details
Type
string
Propertyprotectedarray  $_resourceTypes= 'array()'

Available resource types handled by this resource autoloader
Default valuearray()Details
Type
array

Methods

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

Overloading: methods

Allow retrieving concrete resource object instances using 'get()' 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
Name Type Description
$method string
$args array
Returns
Type Description
mixed
Throws
Exception Description
\Zend_Loader_Exception if method not beginning with 'get' or not matching a valid resource type is called
methodpublic__construct( array|\Zend_Config $options ) : void

Constructor

Parameters
Name Type Description
$options array|\Zend_Config

Configuration options for resource autoloader

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

Add resource type

Parameters
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

Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicaddResourceTypes( 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
Name Type Description
$types array
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicautoload( string $class ) : mixed

Attempt to autoload a class

Parameters
Name Type Description
$class string
Returns
Type Description
mixed False if not matched, otherwise result if include operation
methodpublicclearResourceTypes( ) : \Zend_Loader_Autoloader_Resource

Clear all resource types

Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicgetBasePath( ) : string

Get base path to this set of resources

Returns
Type Description
string
methodpublicgetClassPath( string $class ) : False

Helper method to calculate the correct class path

Parameters
Name Type Description
$class string
Returns
Type Description
False if not matched other wise the correct path
methodpublicgetDefaultResourceType( ) : string|null

Get default resource type to use when calling load()

Returns
Type Description
string|null
methodpublicgetNamespace( ) : string

Get namespace this autoloader handles

Returns
Type Description
string
methodpublicgetResourceTypes( ) : array

Retrieve resource type mappings

Returns
Type Description
array
methodpublichasResourceType( string $type ) : bool

Is the requested resource type defined?

Parameters
Name Type Description
$type string
Returns
Type Description
bool
methodpublicload( 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
Name Type Description
$resource string
$type string
Returns
Type Description
object
Throws
Exception Description
\Zend_Loader_Exception if resource type not specified or invalid
methodpublicremoveResourceType( string $type ) : \Zend_Loader_Autoloader_Resource

Remove the requested resource type

Parameters
Name Type Description
$type string
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicsetBasePath( string $path ) : \Zend_Loader_Autoloader_Resource

Set base path for this set of resources

Parameters
Name Type Description
$path string
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicsetDefaultResourceType( string $type ) : \Zend_Loader_Autoloader_Resource

Set default resource type to use when calling load()

Parameters
Name Type Description
$type string
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicsetNamespace( string $namespace ) : \Zend_Loader_Autoloader_Resource

Set namespace that this autoloader handles

Parameters
Name Type Description
$namespace string
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicsetOptions( array $options ) : \Zend_Loader_Autoloader_Resource

Set class state from options

Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Loader_Autoloader_Resource
methodpublicsetResourceTypes( array $types ) : \Zend_Loader_Autoloader_Resource

Overwrite existing and set multiple resource types at once

Parameters
Name Type Description
$types array
Returns
Type Description
\Zend_Loader_Autoloader_Resource
Details
See
\Zend_Loader_Autoloader_Resource::addResourceTypes()  
Documentation was generated by DocBlox 0.15.1.