# Zend_Application_Resource_ResourceAbstract

`Zend_Application_Resource_ResourceAbstract` es una clase abstracta implementando Zend_Application_Resource_Resource , y es un buen punto de partida para crear sus propios recursos de plugin personalizados.

Nota: esta clase abstracta no implementa el método `init()` ; esto se deja para la definición de extensiones concretas de la clase.

## Zend_Application_Resource_ResourceAbstract Methods

Método | Valor de Retorno | Parámetros | Descripción
--- | --- | --- | ---

`__construct($options = null)`

Void

- `$options` : opcional . Opciones con las cuales establecer el estado del recurso.

El constructor debería permitir pasar opciones con las cuales inicializar el estado.

`setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)`

`Zend_Application_Resource_ResourceAbstract`

- `$bootstrap` : requerido . Padre del bootstrap inicializando este recurso.

Debería permitir registrar el objeto padre del bootstrap.

`getBootstrap()` | `Zend_Application_Bootstrap_Bootstrapper` | N/A | Recuperar la instancia registrada del bootstrap.

`setOptions(array $options)`

`Zend_Application_Resource_ResourceAbstract`

- `$options` : requerido . Opciones con las cuales establecer el estado.

Establecer el estado del recurso.

`getOptions()` | Array | N/A | Recuperar opciones registradas.

## Resource Names

When registering plugin resources, one issue that arises is how you should refer to them from the parent bootstrap class. There are three different mechanisms that may be used, depending on how you have configured the bootstrap and its plugin resources.

First, if your plugins are defined within a defined prefix path, you may refer to them simply by their "short name" -- i.e., the portion of the class name following the class prefix. As an example, the class " `Zend_Application_Resource_View` " may be referenced as simply "View", as the prefix path " `Zend_Application_Resource` " is already registered. You may register them using the full class name or the short name:

    $app = new Zend_Application(APPLICATION_ENV, array(
        'pluginPaths' => array(
            'My_Resource' => 'My/Resource/',
        ),
        'resources' => array(
            // if the following class exists:
            'My_Resource_View' => array(),

            // then this is equivalent:
            'View' => array(),
        ),
    ));

In each case, you can then bootstrap the resource and retrieve it later using the short name:

    $bootstrap->bootstrap('view');
    $view = $bootstrap->getResource('view');

Second, if no matching plugin path is defined, you may still pass a resource by the full class name. In this case, you can reference it using the resource's full class name:

    $app = new Zend_Application(APPLICATION_ENV, array(
        'resources' => array(
            // This will load the standard 'View' resource:
            'View' => array(),

            // While this loads a resource with a specific class name:
            'My_Resource_View' => array(),
        ),
    ));

Obviously, this makes referencing the resource much more verbose:

    $bootstrap->bootstrap('My_Resource_View');
    $view = $bootstrap->getResource('My_Resource_View');

This brings us to the third option. You can specify an explicit name that a given resource class will register as. This can be done by adding a public `$_explicitType` property to the resource plugin class, with a string value; that value will then be used whenever you wish to reference the plugin resource via the bootstrap. As an example, let's define our own view class:

    class My_Resource_View extends Zend_Application_Resource_ResourceAbstract
    {
        public $_explicitType = 'My_View';

        public function init()
        {
            // do some initialization...
        }
    }

We can then bootstrap that resource or retrieve it by the name " `My_View` ":

    $bootstrap->bootstrap('My_View');
    $view = $bootstrap->getResource('My_View');

Using these various naming approaches, you can override existing resources, add your own, mix multiple resources to achieve complex initialization, and more.