File: Zend_Layout-Options.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (225 lines) | stat: -rw-r--r-- 8,859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.layout.options">
    <title>Zend_Layout Configuration Options</title>

    <para>
        <classname>Zend_Layout</classname> has a variety of configuration options. These
        may be set by calling the appropriate accessors, passing an array or
        <classname>Zend_Config</classname> object to the constructor or
        <methodname>startMvc()</methodname>, passing an array of options to
        <methodname>setOptions()</methodname>, or passing a <classname>Zend_Config</classname>
        object to <methodname>setConfig()</methodname>.
    </para>

    <itemizedlist>
        <listitem>
            <para>
                <emphasis>layout</emphasis>: the layout to use. Uses the
                current inflector to resolve the name provided to the
                appropriate layout view script. By default, this value is
                'layout' and resolves to 'layout.phtml'. Accessors
                are <methodname>setLayout()</methodname> and <methodname>getLayout()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>layoutPath</emphasis>: the base path to layout view
                scripts. Accessors are <methodname>setLayoutPath()</methodname> and
                <methodname>getLayoutPath()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>contentKey</emphasis>: the layout variable used for
                default content (when used with the <acronym>MVC</acronym>). Default value is
                'content'. Accessors are <methodname>setContentKey()</methodname> and
                <methodname>getContentKey()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>mvcSuccessfulActionOnly</emphasis>: when using the
                <acronym>MVC</acronym>, if an action throws an exception and this flag is
                <constant>TRUE</constant>, the layout will not be rendered (this is to prevent
                double-rendering of the layout when the <link
                    linkend="zend.controller.plugins.standard.errorhandler">ErrorHandler
                    plugin</link> is in use). By default, the flat is <constant>TRUE</constant>.
                Accessors are <methodname>setMvcSuccessfulActionOnly()</methodname> and
                <methodname>getMvcSuccessfulActionOnly()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>view</emphasis>: the view object to use when rendering. When used with the
                <acronym>MVC</acronym>, <classname>Zend_Layout</classname> will attempt to use the
                view object registered with <link
                    linkend="zend.controller.actionhelpers.viewrenderer">the ViewRenderer</link> if
                no view object has been passed to it explicitly. Accessors are
                <methodname>setView()</methodname> and <methodname>getView()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>helperClass</emphasis>: the action helper class to use
                when using <classname>Zend_Layout</classname> with the <acronym>MVC</acronym>
                components. By default, this is
                <classname>Zend_Layout_Controller_Action_Helper_Layout</classname>.
                Accessors are <methodname>setHelperClass()</methodname> and
                <methodname>getHelperClass()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>pluginClass</emphasis>: the front controller plugin
                class to use when using <classname>Zend_Layout</classname> with the
                <acronym>MVC</acronym> components. By default, this is
                <classname>Zend_Layout_Controller_Plugin_Layout</classname>. Accessors
                are <methodname>setPluginClass()</methodname> and
                <methodname>getPluginClass()</methodname>.
            </para>
        </listitem>

        <listitem>
            <para>
                <emphasis>inflector</emphasis>: the inflector to use when
                resolving layout names to layout view script paths; see <link
                    linkend="zend.layout.advanced.inflector">the
                    <classname>Zend_Layout</classname> inflector documentation for more
                    details</link>. Accessors are <methodname>setInflector()</methodname>
                and <methodname>getInflector()</methodname>.
            </para>
        </listitem>
    </itemizedlist>

    <note>
        <title>helperClass and pluginClass must be passed to startMvc()</title>

        <para>
            In order for the <property>helperClass</property> and
            <property>pluginClass</property> settings to have effect, they must be
            passed in as options to <methodname>startMvc()</methodname>; if set later, they
            have no affect.
        </para>
    </note>

    <sect2 id="zend.layout.options.examples">
        <title>Examples</title>

        <para>
            The following examples assume the following <varname>$options</varname>
            array and <varname>$config</varname> object:
        </para>

        <programlisting language="php"><![CDATA[
$options = array(
    'layout'     => 'foo',
    'layoutPath' => '/path/to/layouts',
    'contentKey' => 'CONTENT',           // ignored when MVC not used
);
]]></programlisting>

        <programlisting language="php"><![CDATA[
/**
[layout]
layout = "foo"
layoutPath = "/path/to/layouts"
contentKey = "CONTENT"
*/
$config = new Zend_Config_Ini('/path/to/layout.ini', 'layout');
]]></programlisting>

        <example id="zend.layout.options.examples.constructor">
            <title>Passing options to the constructor or startMvc()</title>

            <para>
                Both the constructor and the <methodname>startMvc()</methodname> static
                method can accept either an array of options or a
                <classname>Zend_Config</classname> object with options in order to
                configure the <classname>Zend_Layout</classname> instance.
            </para>

            <para>
                First, let's look at passing an array:
            </para>

            <programlisting language="php"><![CDATA[
// Using constructor:
$layout = new Zend_Layout($options);

// Using startMvc():
$layout = Zend_Layout::startMvc($options);
]]></programlisting>

            <para>
                And now using a config object:
            </para>

            <programlisting language="php"><![CDATA[
$config = new Zend_Config_Ini('/path/to/layout.ini', 'layout');

// Using constructor:
$layout = new Zend_Layout($config);

// Using startMvc():
$layout = Zend_Layout::startMvc($config);
]]></programlisting>

            <para>
                Basically, this is the easiest way to customize your
                <classname>Zend_Layout</classname> instance.
            </para>
        </example>

        <example id="zend.layout.options.examples.setoptionsconfig">
            <title>Using setOption() and setConfig()</title>

            <para>
                Sometimes you need to configure the <classname>Zend_Layout</classname>
                object after it has already been instantiated;
                <methodname>setOptions()</methodname> and <methodname>setConfig()</methodname> give
                you a quick and easy way to do so:
            </para>

            <programlisting language="php"><![CDATA[
// Using an array of options:
$layout->setOptions($options);

// Using a Zend_Config object:
$layout->setConfig($options);
]]></programlisting>

            <para>
                Note, however, that certain options, such as
                <property>pluginClass</property> and <property>helperClass</property>, will have
                no affect when passed using this method; they need to be passed
                to the constructor or <methodname>startMvc()</methodname> method.
            </para>
        </example>

        <example id="zend.layout.options.examples.accessors">
            <title>Using Accessors</title>

            <para>
                Finally, you can also configure your <classname>Zend_Layout</classname>
                instance via accessors. All accessors implement a fluent
                interface, meaning their calls may be chained:
            </para>

            <programlisting language="php"><![CDATA[
$layout->setLayout('foo')
       ->setLayoutPath('/path/to/layouts')
       ->setContentKey('CONTENT');
]]></programlisting>
        </example>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->