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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Zend Framework 1.0 - Zend Framework Manual</title>
</head>
<body>
<table width="100%">
<tr valign="top">
<td width="85%">
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="migration.15.html">Zend Framework 1.5</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="migration.html">Zend Gdata Migration Notes</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="migration.09.html">Zend Framework 0.9</a></div>
</td>
</tr>
</table>
<hr />
<div id="migration.10" class="section"><div class="info"><h1 class="title">Zend Framework 1.0</h1></div>
<p class="para">
When upgrading from a previous release to Zend Framework 1.0 or higher you
should note the following migration notes.
</p>
<div class="section" id="migration.10.zend.controller" name="migration.10.zend.controller"><div class="info"><h1 class="title">Zend_Controller</h1></div>
<p class="para">
The principal changes introduced in 1.0.0RC1 are the introduction of
and default enabling of the
<a href="" class="link">ErrorHandler</a>
plugin and the <a href="" class="link">ViewRenderer</a>
action helper. Please read the documentation to each thoroughly to
see how they work and what effect they may have on your
applications.
</p>
<p class="para">
The <span class="classname">ErrorHandler</span> plugin runs during
<span class="methodname">postDispatch()</span> checking for exceptions, and forwarding
to a specified error handler controller. You should include such a
controller in your application. You may disable it by setting the
front controller parameter <span class="property">noErrorHandler</span>:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$front</span>-><span style="color: #006600;">setParam</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'noErrorHandler'</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The <span class="classname">ViewRenderer</span> action helper automates view injection
into action controllers as well as autorendering of view scripts
based on the current action. The primary issue you may encounter is
if you have actions that do not render view scripts and neither
forward or redirect, as the <span class="classname">ViewRenderer</span> will attempt
to render a view script based on the action name.
</p>
<p class="para">
There are several strategies you can take to update your code. In
the short term, you can globally disable the
<span class="classname">ViewRenderer</span> in your front controller bootstrap prior
to dispatching:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Assuming $front is an instance of Zend_Controller_Front</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$front</span>-><span style="color: #006600;">setParam</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'noViewRenderer'</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
However, this is not a good long term strategy, as it means most
likely you'll be writing more code.
</p>
<p class="para">
When you're ready to start using the <span class="classname">ViewRenderer</span>
functionality, there are several things to look for in your
controller code. First, look at your action methods (the methods
ending in 'Action'), and determine what each is doing. If none of
the following is happening, you'll need to make changes:
</p>
<ul class="itemizedlist">
<li class="listitem"><p class="para">Calls to <strong class="command">$this->render();</strong></p></li>
<li class="listitem"><p class="para">Calls to <strong class="command">$this->_forward();</strong></p></li>
<li class="listitem"><p class="para">Calls to <strong class="command">$this->_redirect();</strong></p></li>
<li class="listitem">
<p class="para">Calls to the <span class="classname">Redirector</span> action helper</p>
</li>
</ul>
<p class="para">
The easiest change is to disable auto-rendering for that method:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$this</span>->_helper-><span style="color: #006600;">viewRenderer</span>-><span style="color: #006600;">setNoRender</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
If you find that none of your action methods are rendering,
forwarding, or redirecting, you will likely want to put the above
line in your <span class="methodname">preDispatch()</span> or <span class="methodname">init()</span>
methods:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> preDispatch<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #808080; font-style: italic;">// disable view script autorendering</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$this</span>->_helper-><span style="color: #006600;">viewRenderer</span>-><span style="color: #006600;">setNoRender</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #808080; font-style: italic;">// .. do other things...</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">}</span></div></li></ol></div></div></div>
<p class="para">
If you are calling <span class="methodname">render()</span>, and you're using <a href="" class="link">the Conventional Modular
directory structure</a>, you'll want to change your code to
make use of autorendering:
</p>
<ul class="itemizedlist">
<li class="listitem">
<p class="para">
If you're rendering multiple view scripts in a single
action, you don't need to change a thing.
</p>
</li>
<li class="listitem">
<p class="para">
If you're simply calling <span class="methodname">render()</span> with no
arguments, you can remove such lines.
</p>
</li>
<li class="listitem">
<p class="para">
If you're calling <span class="methodname">render()</span> with arguments, and
not doing any processing afterwards or rendering multiple
view scripts, you can change these calls to read
<strong class="command">$this->_helper->viewRenderer();</strong>.
</p>
</li>
</ul>
<p class="para">
If you're not using the conventional modular directory structure,
there are a variety of methods for setting the view base path and
script path specifications so that you can make use of the
<span class="classname">ViewRenderer</span>. Please read the <a href="" class="link">ViewRenderer
documentation</a> for information on these methods.
</p>
<p class="para">
If you're using a view object from the registry, or customizing your
view object, or using a different view implementation, you'll want
to inject the <span class="classname">ViewRenderer</span> with this object. This can
be done easily at any time.
</p>
<ul class="itemizedlist">
<li class="listitem">
<p class="para">
Prior to dispatching a front controller instance:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Assuming $view has already been defined</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$viewRenderer</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Controller_Action_Helper_ViewRenderer<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$view</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Zend_Controller_Action_HelperBroker::<span style="color: #006600;">addHelper</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$viewRenderer</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</li>
<li class="listitem">
<p class="para">
Any time during the bootstrap process:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$viewRenderer</span> =</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> Zend_Controller_Action_HelperBroker::<span style="color: #006600;">getStaticHelper</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'viewRenderer'</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$viewRenderer</span>-><span style="color: #006600;">setView</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$view</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</li>
</ul>
<p class="para">
There are many ways to modify the <span class="classname">ViewRenderer</span>,
including setting a different view script to render, specifying
replacements for all replaceable elements of a view script path
(including the suffix), choosing a response named segment to
utilize, and more. If you aren't using the conventional modular
directory structure, you can even associate different path
specifications with the <span class="classname">ViewRenderer</span>.
</p>
<p class="para">
We encourage you to adapt your code to use the
<span class="classname">ErrorHandler</span> and <span class="classname">ViewRenderer</span> as they are
now core functionality.
</p>
</div>
<div class="section" id="migration.10.zend.currency" name="migration.10.zend.currency"><div class="info"><h1 class="title">Zend_Currency</h1></div>
<p class="para">
Creating an object of <span class="classname">Zend_Currency</span> has become simpler.
You no longer have to give a script or set it to <b><tt>NULL</tt></b>. The optional
script parameter is now an option which can be set through the
<span class="methodname">setFormat()</span> method.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$currency</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Currency<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$currency</span>, <span style="color: #0000ff;">$locale</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The <span class="methodname">setFormat()</span> method takes now an array of options. These
options are set permanently and override all previously set values. Also a new option
'precision' has been added. The following options have been refactored:
</p>
<ul class="itemizedlist">
<li class="listitem">
<p class="para">
<em class="emphasis">position</em>:
Replacement for the old 'rules' parameter.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">script</em>:
Replacement for the old 'script' parameter.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">format</em>:
Replacement for the old 'locale' parameter which does not
set new currencies but only the number format.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">display</em>:
Replacement for the old 'rules' parameter.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">precision</em>:
New parameter.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">name</em>:
Replacement for the ole 'rules' parameter. Sets the full
currencies name.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">currency</em>:
New parameter.
</p>
</li>
<li class="listitem">
<p class="para">
<em class="emphasis">symbol</em>:
New parameter.
</p>
</li>
</ul>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$currency</span>-><span style="color: #006600;">setFormat</span><span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #0000ff;">$options</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The <span class="methodname">toCurrency()</span> method no longer supports the optional
'script' and 'locale' parameters. Instead it takes an options array which
can contain the same keys as for the <span class="methodname">setFormat()</span> method.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$currency</span>-><span style="color: #006600;">toCurrency</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$value</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #0000ff;">$options</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The methods <span class="methodname">getSymbol()</span>,
<span class="methodname">getShortName()</span>, <span class="methodname">getName()</span>,
<span class="methodname">getRegionList()</span> and
<span class="methodname">getCurrencyList()</span> are no longer static and can be called
from within the object. They return the set values of the object if no
parameter has been set.
</p>
</div>
</div>
<hr />
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="migration.15.html">Zend Framework 1.5</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="migration.html">Zend Gdata Migration Notes</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="migration.09.html">Zend Framework 0.9</a></div>
</td>
</tr>
</table>
</td>
<td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
float: left;
width: 186px;
padding: 5px;
font-size: smaller;
}
ul.toc {
margin: 0px 5px 5px 5px;
padding: 0px;
}
ul.toc li {
font-size: 85%;
margin: 1px 0 1px 1px;
padding: 1px 0 1px 11px;
list-style-type: none;
background-repeat: no-repeat;
background-position: center left;
}
ul.toc li.header {
font-size: 115%;
padding: 5px 0px 5px 11px;
border-bottom: 1px solid #cccccc;
margin-bottom: 5px;
}
ul.toc li.active {
font-weight: bold;
}
ul.toc li a {
text-decoration: none;
}
ul.toc li a:hover {
text-decoration: underline;
}
</style>
<ul class="toc">
<li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="migration.html">Zend Gdata Migration Notes</a></li>
<li><a href="migration.112.html">Zend Framework 1.12</a></li>
<li><a href="migration.110.html">Zend Framework 1.10</a></li>
<li><a href="migration.19.html">Zend Framework 1.9</a></li>
<li><a href="migration.18.html">Zend Framework 1.8</a></li>
<li><a href="migration.17.html">Zend Framework 1.7</a></li>
<li><a href="migration.16.html">Zend Framework 1.6</a></li>
<li><a href="migration.15.html">Zend Framework 1.5</a></li>
<li class="active"><a href="migration.10.html">Zend Framework 1.0</a></li>
<li><a href="migration.09.html">Zend Framework 0.9</a></li>
<li><a href="migration.08.html">Zend Framework 0.8</a></li>
<li><a href="migration.06.html">Zend Framework 0.6</a></li>
</ul>
</td>
</tr>
</table>
</body>
</html>
|