1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- EN-Revision: 20763 -->
4 <sect2 id="zend.application.core-functionality.resource-resourceabstract">
5 <title>Zend_Application_Resource_ResourceAbstract</title>
8 <classname>Zend_Application_Resource_ResourceAbstract</classname>
11 <link linkend="zend.application.core-functionality.resource-resource">Zend_Application_Resource_Resource</link>
13 y es un buen punto de partida para crear sus propios recursos de plugin
18 Nota: esta clase abstracta no implementa el método
19 <methodname>init()</methodname>
21 esto se deja para la definición de extensiones concretas de la clase.
24 <table id="zend.application.core-functionality.resource-resourceabstract.api">
25 <title>Zend_Application_Resource_ResourceAbstract Methods</title>
30 <entry>Valor de Retorno</entry>
31 <entry>Parámetros</entry>
32 <entry>Descripción</entry>
38 <methodname>__construct($options = null)</methodname>
47 <varname>$options</varname>
49 <emphasis>opcional</emphasis>
51 Opciones con las cuales establecer el estado del recurso.
58 El constructor debería permitir pasar opciones con las
59 cuales inicializar el estado.
66 <methodname>setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)</methodname>
69 <classname>Zend_Application_Resource_ResourceAbstract</classname>
75 <varname>$bootstrap</varname>
77 <emphasis>requerido</emphasis>
79 Padre del bootstrap inicializando este recurso.
86 Debería permitir registrar el objeto padre del bootstrap.
93 <methodname>getBootstrap()</methodname>
96 <classname>Zend_Application_Bootstrap_Bootstrapper</classname>
101 Recuperar la instancia registrada del bootstrap.
108 <methodname>setOptions(array $options)</methodname>
111 <classname>Zend_Application_Resource_ResourceAbstract</classname>
117 <varname>$options</varname>
119 <emphasis>requerido</emphasis>
121 Opciones con las cuales establecer el estado.
128 Establecer el estado del recurso.
135 <methodname>getOptions()</methodname>
143 Recuperar opciones registradas.
150 <sect3 id="zend.application.core-functionality.resource-resourceabstract.names">
151 <title>Resource Names</title>
154 When registering plugin resources, one issue that arises is how you
156 them from the parent bootstrap class. There are
157 three different mechanisms that may be
158 used, depending on how you
159 have configured the bootstrap and its plugin resources.
163 First, if your plugins are defined within a defined prefix path, you
165 simply by their "short name" -- i.e., the portion
166 of the class name following the class
167 prefix. As an example, the
169 <classname>Zend_Application_Resource_View</classname>
170 " may be referenced as
171 simply "View", as the prefix path "
172 <classname>Zend_Application_Resource</classname>
174 is already registered. You may register them using the full class name or the
179 <programlisting language="php"><![CDATA[
180 $app = new Zend_Application(APPLICATION_ENV, array(
181 'pluginPaths' => array(
182 'My_Resource' => 'My/Resource/',
184 'resources' => array(
185 // if the following class exists:
186 'My_Resource_View' => array(),
188 // then this is equivalent:
195 In each case, you can then bootstrap the resource and retrieve it
196 later using the short
200 <programlisting language="php"><![CDATA[
201 $bootstrap->bootstrap('view');
202 $view = $bootstrap->getResource('view');
206 Second, if no matching plugin path is defined, you may still pass a
208 full class name. In this case, you can reference it
209 using the resource's full class name:
212 <programlisting language="php"><![CDATA[
213 $app = new Zend_Application(APPLICATION_ENV, array(
214 'resources' => array(
215 // This will load the standard 'View' resource:
218 // While this loads a resource with a specific class name:
219 'My_Resource_View' => array(),
225 Obviously, this makes referencing the resource much more verbose:
228 <programlisting language="php"><![CDATA[
229 $bootstrap->bootstrap('My_Resource_View');
230 $view = $bootstrap->getResource('My_Resource_View');
234 This brings us to the third option. You can specify an explicit name
236 resource class will register as. This can be done by
238 <varname>$_explicitType</varname>
239 property to the resource
240 plugin class, with a string value; that value will then be used
241 whenever you wish to reference the plugin resource via the
242 bootstrap. As an example,
243 let's define our own view class:
246 <programlisting language="php"><![CDATA[
247 class My_Resource_View extends Zend_Application_Resource_ResourceAbstract
249 public $_explicitType = 'My_View';
251 public function init()
253 // do some initialization...
259 We can then bootstrap that resource or retrieve it by the name
261 <classname>My_View</classname>
265 <programlisting language="php"><![CDATA[
266 $bootstrap->bootstrap('My_View');
267 $view = $bootstrap->getResource('My_View');
271 Using these various naming approaches, you can override existing
273 own, mix multiple resources to achieve complex
274 initialization, and more.