migration-10.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="migration.10">
  4. <title>Zend Framework 1.0</title>
  5. <para>
  6. When upgrading from a previous release to Zend Framework 1.0 or higher you
  7. should note the following migration notes.
  8. </para>
  9. <sect2 id="migration.10.zend.controller">
  10. <title>Zend_Controller</title>
  11. <para>
  12. The principal changes introduced in 1.0.0RC1 are the introduction of
  13. and default enabling of the
  14. <link
  15. linkend="zend.controller.plugins.standard.errorhandler">ErrorHandler</link>
  16. plugin and the <link
  17. linkend="zend.controller.actionhelpers.viewrenderer">ViewRenderer</link>
  18. action helper. Please read the documentation to each thoroughly to
  19. see how they work and what effect they may have on your
  20. applications.
  21. </para>
  22. <para>
  23. The <classname>ErrorHandler</classname> plugin runs during
  24. <methodname>postDispatch()</methodname> checking for exceptions, and forwarding
  25. to a specified error handler controller. You should include such a
  26. controller in your application. You may disable it by setting the
  27. front controller parameter <property>noErrorHandler</property>:
  28. </para>
  29. <programlisting language="php"><![CDATA[
  30. $front->setParam('noErrorHandler', true);
  31. ]]></programlisting>
  32. <para>
  33. The <classname>ViewRenderer</classname> action helper automates view injection
  34. into action controllers as well as autorendering of view scripts
  35. based on the current action. The primary issue you may encounter is
  36. if you have actions that do not render view scripts and neither
  37. forward or redirect, as the <classname>ViewRenderer</classname> will attempt
  38. to render a view script based on the action name.
  39. </para>
  40. <para>
  41. There are several strategies you can take to update your code. In
  42. the short term, you can globally disable the
  43. <classname>ViewRenderer</classname> in your front controller bootstrap prior
  44. to dispatching:
  45. </para>
  46. <programlisting language="php"><![CDATA[
  47. // Assuming $front is an instance of Zend_Controller_Front
  48. $front->setParam('noViewRenderer', true);
  49. ]]></programlisting>
  50. <para>
  51. However, this is not a good long term strategy, as it means most
  52. likely you'll be writing more code.
  53. </para>
  54. <para>
  55. When you're ready to start using the <classname>ViewRenderer</classname>
  56. functionality, there are several things to look for in your
  57. controller code. First, look at your action methods (the methods
  58. ending in 'Action'), and determine what each is doing. If none of
  59. the following is happening, you'll need to make changes:
  60. </para>
  61. <itemizedlist>
  62. <listitem><para>Calls to <command>$this->render();</command></para></listitem>
  63. <listitem><para>Calls to <command>$this->_forward();</command></para></listitem>
  64. <listitem><para>Calls to <command>$this->_redirect();</command></para></listitem>
  65. <listitem>
  66. <para>Calls to the <classname>Redirector</classname> action helper</para>
  67. </listitem>
  68. </itemizedlist>
  69. <para>
  70. The easiest change is to disable auto-rendering for that method:
  71. </para>
  72. <programlisting language="php"><![CDATA[
  73. $this->_helper->viewRenderer->setNoRender();
  74. ]]></programlisting>
  75. <para>
  76. If you find that none of your action methods are rendering,
  77. forwarding, or redirecting, you will likely want to put the above
  78. line in your <methodname>preDispatch()</methodname> or <methodname>init()</methodname>
  79. methods:
  80. </para>
  81. <programlisting language="php"><![CDATA[
  82. public function preDispatch()
  83. {
  84. // disable view script autorendering
  85. $this->_helper->viewRenderer->setNoRender()
  86. // .. do other things...
  87. }
  88. ]]></programlisting>
  89. <para>
  90. If you are calling <methodname>render()</methodname>, and you're using <link
  91. linkend="zend.controller.modular">the Conventional Modular
  92. directory structure</link>, you'll want to change your code to
  93. make use of autorendering:
  94. </para>
  95. <itemizedlist>
  96. <listitem>
  97. <para>
  98. If you're rendering multiple view scripts in a single
  99. action, you don't need to change a thing.
  100. </para>
  101. </listitem>
  102. <listitem>
  103. <para>
  104. If you're simply calling <methodname>render()</methodname> with no
  105. arguments, you can remove such lines.
  106. </para>
  107. </listitem>
  108. <listitem>
  109. <para>
  110. If you're calling <methodname>render()</methodname> with arguments, and
  111. not doing any processing afterwards or rendering multiple
  112. view scripts, you can change these calls to read
  113. <command>$this->_helper->viewRenderer();</command>.
  114. </para>
  115. </listitem>
  116. </itemizedlist>
  117. <para>
  118. If you're not using the conventional modular directory structure,
  119. there are a variety of methods for setting the view base path and
  120. script path specifications so that you can make use of the
  121. <classname>ViewRenderer</classname>. Please read the <link
  122. linkend="zend.controller.actionhelpers.viewrenderer">ViewRenderer
  123. documentation</link> for information on these methods.
  124. </para>
  125. <para>
  126. If you're using a view object from the registry, or customizing your
  127. view object, or using a different view implementation, you'll want
  128. to inject the <classname>ViewRenderer</classname> with this object. This can
  129. be done easily at any time.
  130. </para>
  131. <itemizedlist>
  132. <listitem>
  133. <para>
  134. Prior to dispatching a front controller instance:
  135. </para>
  136. <programlisting language="php"><![CDATA[
  137. // Assuming $view has already been defined
  138. $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
  139. Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
  140. ]]></programlisting>
  141. </listitem>
  142. <listitem>
  143. <para>
  144. Any time during the bootstrap process:
  145. </para>
  146. <programlisting language="php"><![CDATA[
  147. $viewRenderer =
  148. Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
  149. $viewRenderer->setView($view);
  150. ]]></programlisting>
  151. </listitem>
  152. </itemizedlist>
  153. <para>
  154. There are many ways to modify the <classname>ViewRenderer</classname>,
  155. including setting a different view script to render, specifying
  156. replacements for all replaceable elements of a view script path
  157. (including the suffix), choosing a response named segment to
  158. utilize, and more. If you aren't using the conventional modular
  159. directory structure, you can even associate different path
  160. specifications with the <classname>ViewRenderer</classname>.
  161. </para>
  162. <para>
  163. We encourage you to adapt your code to use the
  164. <classname>ErrorHandler</classname> and <classname>ViewRenderer</classname> as they are
  165. now core functionality.
  166. </para>
  167. </sect2>
  168. <sect2 id="migration.10.zend.currency">
  169. <title>Zend_Currency</title>
  170. <para>
  171. Creating an object of <classname>Zend_Currency</classname> has become simpler.
  172. You no longer have to give a script or set it to <constant>NULL</constant>. The optional
  173. script parameter is now an option which can be set through the
  174. <methodname>setFormat()</methodname> method.
  175. </para>
  176. <programlisting language="php"><![CDATA[
  177. $currency = new Zend_Currency($currency, $locale);
  178. ]]></programlisting>
  179. <para>
  180. The <methodname>setFormat()</methodname> method takes now an array of options. These
  181. options are set permanently and override all previously set values. Also a new option
  182. 'precision' has been added. The following options have been refactored:
  183. </para>
  184. <itemizedlist mark='opencircle'>
  185. <listitem>
  186. <para>
  187. <emphasis>position</emphasis>:
  188. Replacement for the old 'rules' parameter.
  189. </para>
  190. </listitem>
  191. <listitem>
  192. <para>
  193. <emphasis>script</emphasis>:
  194. Replacement for the old 'script' parameter.
  195. </para>
  196. </listitem>
  197. <listitem>
  198. <para>
  199. <emphasis>format</emphasis>:
  200. Replacement for the old 'locale' parameter which does not
  201. set new currencies but only the number format.
  202. </para>
  203. </listitem>
  204. <listitem>
  205. <para>
  206. <emphasis>display</emphasis>:
  207. Replacement for the old 'rules' parameter.
  208. </para>
  209. </listitem>
  210. <listitem>
  211. <para>
  212. <emphasis>precision</emphasis>:
  213. New parameter.
  214. </para>
  215. </listitem>
  216. <listitem>
  217. <para>
  218. <emphasis>name</emphasis>:
  219. Replacement for the ole 'rules' parameter. Sets the full
  220. currencies name.
  221. </para>
  222. </listitem>
  223. <listitem>
  224. <para>
  225. <emphasis>currency</emphasis>:
  226. New parameter.
  227. </para>
  228. </listitem>
  229. <listitem>
  230. <para>
  231. <emphasis>symbol</emphasis>:
  232. New parameter.
  233. </para>
  234. </listitem>
  235. </itemizedlist>
  236. <programlisting language="php"><![CDATA[
  237. $currency->setFormat(array $options);
  238. ]]></programlisting>
  239. <para>
  240. The <methodname>toCurrency()</methodname> method no longer supports the optional
  241. 'script' and 'locale' parameters. Instead it takes an options array which
  242. can contain the same keys as for the <methodname>setFormat()</methodname> method.
  243. </para>
  244. <programlisting language="php"><![CDATA[
  245. $currency->toCurrency($value, array $options);
  246. ]]></programlisting>
  247. <para>
  248. The methods <methodname>getSymbol()</methodname>,
  249. <methodname>getShortName()</methodname>, <methodname>getName()</methodname>,
  250. <methodname>getRegionList()</methodname> and
  251. <methodname>getCurrencyList()</methodname> are no longer static and can be called
  252. from within the object. They return the set values of the object if no
  253. parameter has been set.
  254. </para>
  255. </sect2>
  256. </sect1>
  257. <!--
  258. vim:se ts=4 sw=4 et:
  259. -->