[ZF-10089] Zend_Log
[zend.git] / documentation / manual / es / module_specs / Zend_Application-CoreFunctionality-Resource_ResourceAbstract.xml
blob7369a2670667204af8f6b682af0b3ef94eed02fc
1 <?xml version="1.0" encoding="UTF-8"?>
2     <!-- EN-Revision: 20763 -->
3     <!-- Reviewed: no -->
4 <sect2 id="zend.application.core-functionality.resource-resourceabstract">
5     <title>Zend_Application_Resource_ResourceAbstract</title>
7     <para>
8         <classname>Zend_Application_Resource_ResourceAbstract</classname>
9         es una clase abstracta
10         implementando
11         <link linkend="zend.application.core-functionality.resource-resource">Zend_Application_Resource_Resource</link>
12         ,
13         y es un buen punto de partida para crear sus propios recursos de plugin
14         personalizados.
15     </para>
17     <para>
18         Nota: esta clase abstracta no implementa el método
19         <methodname>init()</methodname>
20         ;
21         esto se deja para la definición de extensiones concretas de la clase.
22     </para>
24     <table id="zend.application.core-functionality.resource-resourceabstract.api">
25         <title>Zend_Application_Resource_ResourceAbstract Methods</title>
26         <tgroup cols="4">
27             <thead>
28                 <row>
29                     <entry>Método</entry>
30                     <entry>Valor de Retorno</entry>
31                     <entry>Parámetros</entry>
32                     <entry>Descripción</entry>
33                 </row>
34             </thead>
35             <tbody>
36                 <row>
37                     <entry>
38                         <methodname>__construct($options = null)</methodname>
39                     </entry>
40                     <entry>
41                         <type>Void</type>
42                     </entry>
43                     <entry>
44                         <itemizedlist>
45                             <listitem>
46                                 <para>
47                                     <varname>$options</varname>
48                                     :
49                                     <emphasis>opcional</emphasis>
50                                     .
51                                     Opciones con las cuales establecer el estado del recurso.
52                                 </para>
53                             </listitem>
54                         </itemizedlist>
55                     </entry>
56                     <entry>
57                         <para>
58                             El constructor debería permitir pasar opciones con las
59                             cuales inicializar el estado.
60                    </para>
61                     </entry>
62                 </row>
64                 <row>
65                     <entry>
66                         <methodname>setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)</methodname>
67                     </entry>
68                     <entry>
69                         <classname>Zend_Application_Resource_ResourceAbstract</classname>
70                     </entry>
71                     <entry>
72                         <itemizedlist>
73                             <listitem>
74                                 <para>
75                                     <varname>$bootstrap</varname>
76                                     :
77                                     <emphasis>requerido</emphasis>
78                                     .
79                                     Padre del bootstrap inicializando este recurso.
80                                 </para>
81                             </listitem>
82                         </itemizedlist>
83                     </entry>
84                     <entry>
85                         <para>
86                             Debería permitir registrar el objeto padre del bootstrap.
87                    </para>
88                     </entry>
89                 </row>
91                 <row>
92                     <entry>
93                         <methodname>getBootstrap()</methodname>
94                     </entry>
95                     <entry>
96                         <classname>Zend_Application_Bootstrap_Bootstrapper</classname>
97                     </entry>
98                     <entry>N/A</entry>
99                     <entry>
100                         <para>
101                             Recuperar la instancia registrada del bootstrap.
102                    </para>
103                     </entry>
104                 </row>
106                 <row>
107                     <entry>
108                         <methodname>setOptions(array $options)</methodname>
109                     </entry>
110                     <entry>
111                         <classname>Zend_Application_Resource_ResourceAbstract</classname>
112                     </entry>
113                     <entry>
114                         <itemizedlist>
115                             <listitem>
116                                 <para>
117                                     <varname>$options</varname>
118                                     :
119                                     <emphasis>requerido</emphasis>
120                                     .
121                                     Opciones con las cuales establecer el estado.
122                                 </para>
123                             </listitem>
124                         </itemizedlist>
125                     </entry>
126                     <entry>
127                         <para>
128                             Establecer el estado del recurso.
129                    </para>
130                     </entry>
131                 </row>
133                 <row>
134                     <entry>
135                         <methodname>getOptions()</methodname>
136                     </entry>
137                     <entry>
138                         <type>Array</type>
139                     </entry>
140                     <entry>N/A</entry>
141                     <entry>
142                         <para>
143                             Recuperar opciones registradas.
144                    </para>
145                     </entry>
146                 </row>
147             </tbody>
148         </tgroup>
149     </table>
150     <sect3 id="zend.application.core-functionality.resource-resourceabstract.names">
151         <title>Resource Names</title>
153         <para>
154             When registering plugin resources, one issue that arises is how you
155             should refer to
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.
160        </para>
162         <para>
163             First, if your plugins are defined within a defined prefix path, you
164             may refer to them
165             simply by their "short name" -- i.e., the portion
166             of the class name following the class
167             prefix. As an example, the
168             class "
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>
173             "
174             is already registered. You may register them using the full class name or the
175             short
176             name:
177         </para>
179         <programlisting language="php"><![CDATA[
180 $app = new Zend_Application(APPLICATION_ENV, array(
181     'pluginPaths' => array(
182         'My_Resource' => 'My/Resource/',
183     ),
184     'resources' => array(
185         // if the following class exists:
186         'My_Resource_View' => array(),
188         // then this is equivalent:
189         'View' => array(),
190     ),
192 ]]></programlisting>
194         <para>
195             In each case, you can then bootstrap the resource and retrieve it
196             later using the short
197             name:
198        </para>
200         <programlisting language="php"><![CDATA[
201 $bootstrap->bootstrap('view');
202 $view = $bootstrap->getResource('view');
203 ]]></programlisting>
205         <para>
206             Second, if no matching plugin path is defined, you may still pass a
207             resource by the
208             full class name. In this case, you can reference it
209             using the resource's full class name:
210        </para>
212         <programlisting language="php"><![CDATA[
213 $app = new Zend_Application(APPLICATION_ENV, array(
214     'resources' => array(
215         // This will load the standard 'View' resource:
216         'View' => array(),
218         // While this loads a resource with a specific class name:
219         'My_Resource_View' => array(),
220     ),
222 ]]></programlisting>
224         <para>
225             Obviously, this makes referencing the resource much more verbose:
226        </para>
228         <programlisting language="php"><![CDATA[
229 $bootstrap->bootstrap('My_Resource_View');
230 $view = $bootstrap->getResource('My_Resource_View');
231 ]]></programlisting>
233         <para>
234             This brings us to the third option. You can specify an explicit name
235             that a given
236             resource class will register as. This can be done by
237             adding a public
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:
244         </para>
246         <programlisting language="php"><![CDATA[
247 class My_Resource_View extends Zend_Application_Resource_ResourceAbstract
249     public $_explicitType = 'My_View';
251     public function init()
252     {
253         // do some initialization...
254     }
256 ]]></programlisting>
258         <para>
259             We can then bootstrap that resource or retrieve it by the name
260             "
261             <classname>My_View</classname>
262             ":
263         </para>
265         <programlisting language="php"><![CDATA[
266 $bootstrap->bootstrap('My_View');
267 $view = $bootstrap->getResource('My_View');
268 ]]></programlisting>
270         <para>
271             Using these various naming approaches, you can override existing
272             resources, add your
273             own, mix multiple resources to achieve complex
274             initialization, and more.
275        </para>
276     </sect3>
277 </sect2>