Loader/Autoloader/Resource.php

Show: PublicProtectedPrivateinherited
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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Loader  
Subpackage
Autoloader  
Version
$Id$  

\Zend_Loader_Autoloader_Resource

Package: Zend_Loader\Autoloader
Resource loader
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

>VPropertyprotectedstring $_basePath

Base path to resource classes

Details
Type
string
>VPropertyprotectedarray $_components = array()

Components handled within this resource

Default valuearray()Details
Type
array
>VPropertyprotectedstring $_defaultResourceType

Default resource/component to use when using object registry

Details
Type
string
>VPropertyprotectedstring $_namespace

Namespace of classes within this resource

Details
Type
string
>VPropertyprotectedarray $_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
NameTypeDescription
$methodstring
$argsarray
Returns
TypeDescription
mixed
Throws
ExceptionDescription
\Zend_Loader_Exceptionif method not beginning with 'get' or not matching a valid resource type is called
methodpublic__construct(array | \Zend_Config $options) : void

Constructor

Parameters
NameTypeDescription
$optionsarray | \Zend_Config

Configuration options for resource autoloader

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

Add resource type

Parameters
NameTypeDescription
$typestring

identifier for the resource type being loaded

$pathstring

path relative to resource base path containing the resource types

$namespacenull | string

sub-component namespace to append to base namespace that qualifies this resource type

Returns
TypeDescription
\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
NameTypeDescription
$typesarray
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicautoload(string $class) : mixed

Attempt to autoload a class

Parameters
NameTypeDescription
$classstring
Returns
TypeDescription
mixedFalse if not matched, otherwise result if include operation
methodpublicclearResourceTypes() : \Zend_Loader_Autoloader_Resource

Clear all resource types

Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicgetBasePath() : string

Get base path to this set of resources

Returns
TypeDescription
string
methodpublicgetClassPath(string $class) : False

Helper method to calculate the correct class path

Parameters
NameTypeDescription
$classstring
Returns
TypeDescription
Falseif not matched other wise the correct path
methodpublicgetDefaultResourceType() : string | null

Get default resource type to use when calling load()

Returns
TypeDescription
string | null
methodpublicgetNamespace() : string

Get namespace this autoloader handles

Returns
TypeDescription
string
methodpublicgetResourceTypes() : array

Retrieve resource type mappings

Returns
TypeDescription
array
methodpublichasResourceType(string $type) : bool

Is the requested resource type defined?

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
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
NameTypeDescription
$resourcestring
$typestring
Returns
TypeDescription
object
Throws
ExceptionDescription
\Zend_Loader_Exceptionif resource type not specified or invalid
methodpublicremoveResourceType(string $type) : \Zend_Loader_Autoloader_Resource

Remove the requested resource type

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicsetBasePath(string $path) : \Zend_Loader_Autoloader_Resource

Set base path for this set of resources

Parameters
NameTypeDescription
$pathstring
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicsetDefaultResourceType(string $type) : \Zend_Loader_Autoloader_Resource

Set default resource type to use when calling load()

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicsetNamespace(string $namespace) : \Zend_Loader_Autoloader_Resource

Set namespace that this autoloader handles

Parameters
NameTypeDescription
$namespacestring
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicsetOptions(array $options) : \Zend_Loader_Autoloader_Resource

Set class state from options

Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
methodpublicsetResourceTypes(array $types) : \Zend_Loader_Autoloader_Resource

Overwrite existing and set multiple resource types at once

Parameters
NameTypeDescription
$typesarray
Returns
TypeDescription
\Zend_Loader_Autoloader_Resource
Details
See
 
Documentation was generated by phpDocumentor 2.2.0 .