<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: 16649 -->
<!-- Reviewed: no -->
<sect2 id="zend.application.core-functionality.resource-resourceabstract">
    <title>Zend_Application_Resource_ResourceAbstract</title>

    <para>
        <classname>Zend_Application_Resource_ResourceAbstract</classname> es una clase abstracta
        implementando <link linkend="zend.application.core-functionality.resource-resource">Zend_Application_Resource_Resource</link>,
        y es un buen punto de partida para crear sus propios recursos de plugin
        personalizados.
    </para>

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

    <table id="zend.application.core-functionality.resource-resourceabstract.api">
        <title>Zend_Application_Resource_ResourceAbstract Methods</title>
        <tgroup cols="4">
            <thead>
                <row>
                    <entry>Método</entry>
                    <entry>Valor de Retorno</entry>
                    <entry>Parámetros</entry>
                    <entry>Descripción</entry>
                </row>
            </thead>
            <tbody>
                <row>
                    <entry><methodname>__construct($options = null)</methodname></entry>
                    <entry><type>Void</type></entry>
                    <entry><itemizedlist>
                        <listitem><para>
                            <varname>$options</varname>: <emphasis>opcional</emphasis>.
                            Opciones con las cuales establecer el estado del recurso.
                        </para></listitem>
                    </itemizedlist></entry>
                    <entry><para>
                        El constructor debería permitir pasar opciones con las
                        cuales inicializar el estado.
                    </para></entry>
                </row>

                <row>
                    <entry><methodname>setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)</methodname></entry>
                    <entry><classname>Zend_Application_Resource_ResourceAbstract</classname></entry>
                    <entry><itemizedlist>
                            <listitem><para>
                                <varname>$bootstrap</varname>: <emphasis>requerido</emphasis>.
                                Padre del bootstrap inicializando este recurso.
                            </para></listitem>
                    </itemizedlist></entry>
                    <entry><para>
                        Debería permitir registrar el objeto padre del bootstrap.
                    </para></entry>
                </row>

                <row>
                    <entry><methodname>getBootstrap()</methodname></entry>
                    <entry><classname>Zend_Application_Bootstrap_Bootstrapper</classname></entry>
                    <entry>N/A</entry>
                    <entry><para>
                        Recuperar la instancia registrada del bootstrap.
                    </para></entry>
                </row>

                <row>
                    <entry><methodname>setOptions(array $options)</methodname></entry>
                    <entry><classname>Zend_Application_Resource_ResourceAbstract</classname></entry>
                    <entry><itemizedlist>
                        <listitem><para>
                            <varname>$options</varname>: <emphasis>requerido</emphasis>.
                            Opciones con las cuales establecer el estado.
                        </para></listitem>
                    </itemizedlist></entry>
                    <entry><para>
                        Establecer el estado del recurso.
                    </para></entry>
                </row>

                <row>
                    <entry><methodname>getOptions()</methodname></entry>
                    <entry><type>Array</type></entry>
                    <entry>N/A</entry>
                    <entry><para>
                        Recuperar opciones registradas.
                    </para></entry>
                </row>
            </tbody>
        </tgroup>
    </table>
    <sect3 id="zend.application.core-functionality.resource-resourceabstract.names">
        <title>Resource Names</title>
        
        <para>
            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.
        </para>
        
        <para>
            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 "<classname>Zend_Application_Resource_View</classname>" may be referenced as
            simply "View", as the prefix path "<classname>Zend_Application_Resource</classname>"
            is already registered. You may register them using the full class name or the
            short name:
        </para>
        
        <programlisting language="php"><![CDATA[
$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(),
    ),
));
]]></programlisting>
        
        <para>
            In each case, you can then bootstrap the resource and retrieve it
            later using the short name:
        </para>
        
        <programlisting language="php"><![CDATA[
$bootstrap->bootstrap('view');
$view = $bootstrap->getResource('view');
]]></programlisting>
        
        <para>
            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:
        </para>
        
        <programlisting language="php"><![CDATA[
$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(),
    ),
));
]]></programlisting>
        
        <para>
            Obviously, this makes referencing the resource much more verbose:
        </para>
        
        <programlisting language="php"><![CDATA[
$bootstrap->bootstrap('My_Resource_View');
$view = $bootstrap->getResource('My_Resource_View');
]]></programlisting>
        
        <para>
            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 <varname>$_explicitType</varname> 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:
        </para>
        
        <programlisting language="php"><![CDATA[
class My_Resource_View extends Zend_Application_Resource_ResourceAbstract
{
    public $_explicitType = 'My_View';

    public function init()
    {
        // do some initialization...
    }
}
]]></programlisting>
        
        <para>
            We can then bootstrap that resource or retrieve it by the name
            "<classname>My_View</classname>":
        </para>
        
        <programlisting language="php"><![CDATA[
$bootstrap->bootstrap('My_View');
$view = $bootstrap->getResource('My_View');
]]></programlisting>
        
        <para>
            Using these various naming approaches, you can override existing
            resources, add your own, mix multiple resources to achieve complex
            initialization, and more.
        </para>
    </sect3>
</sect2>

