migration-10.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.7 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>
  63. <para>Calls to <command>$this->render();</command></para>
  64. </listitem>
  65. <listitem>
  66. <para>Calls to <command>$this->_forward();</command></para>
  67. </listitem>
  68. <listitem>
  69. <para>Calls to <command>$this->_redirect();</command></para>
  70. </listitem>
  71. <listitem>
  72. <para>Calls to the <classname>Redirector</classname> action helper</para>
  73. </listitem>
  74. </itemizedlist>
  75. <para>
  76. The easiest change is to disable auto-rendering for that method:
  77. </para>
  78. <programlisting language="php"><![CDATA[
  79. $this->_helper->viewRenderer->setNoRender();
  80. ]]></programlisting>
  81. <para>
  82. If you find that none of your action methods are rendering,
  83. forwarding, or redirecting, you will likely want to put the above
  84. line in your <methodname>preDispatch()</methodname> or <methodname>init()</methodname>
  85. methods:
  86. </para>
  87. <programlisting language="php"><![CDATA[
  88. public function preDispatch()
  89. {
  90. // disable view script autorendering
  91. $this->_helper->viewRenderer->setNoRender()
  92. // .. do other things...
  93. }
  94. ]]></programlisting>
  95. <para>
  96. If you are calling <methodname>render()</methodname>, and you're using <link
  97. linkend="zend.controller.modular">the Conventional Modular
  98. directory structure</link>, you'll want to change your code to
  99. make use of autorendering:
  100. </para>
  101. <itemizedlist>
  102. <listitem>
  103. <para>
  104. If you're rendering multiple view scripts in a single
  105. action, you don't need to change a thing.
  106. </para>
  107. </listitem>
  108. <listitem>
  109. <para>
  110. If you're simply calling <methodname>render()</methodname> with no
  111. arguments, you can remove such lines.
  112. </para>
  113. </listitem>
  114. <listitem>
  115. <para>
  116. If you're calling <methodname>render()</methodname> with arguments, and
  117. not doing any processing afterwards or rendering multiple
  118. view scripts, you can change these calls to read
  119. <command>$this->_helper->viewRenderer();</command>.
  120. </para>
  121. </listitem>
  122. </itemizedlist>
  123. <para>
  124. If you're not using the conventional modular directory structure,
  125. there are a variety of methods for setting the view base path and
  126. script path specifications so that you can make use of the
  127. <classname>ViewRenderer</classname>. Please read the <link
  128. linkend="zend.controller.actionhelpers.viewrenderer">ViewRenderer
  129. documentation</link> for information on these methods.
  130. </para>
  131. <para>
  132. If you're using a view object from the registry, or customizing your
  133. view object, or using a different view implementation, you'll want
  134. to inject the <classname>ViewRenderer</classname> with this object. This can
  135. be done easily at any time.
  136. </para>
  137. <itemizedlist>
  138. <listitem>
  139. <para>
  140. Prior to dispatching a front controller instance:
  141. </para>
  142. <programlisting language="php"><![CDATA[
  143. // Assuming $view has already been defined
  144. $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
  145. Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
  146. ]]></programlisting>
  147. </listitem>
  148. <listitem>
  149. <para>
  150. Any time during the bootstrap process:
  151. </para>
  152. <programlisting language="php"><![CDATA[
  153. $viewRenderer =
  154. Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
  155. $viewRenderer->setView($view);
  156. ]]></programlisting>
  157. </listitem>
  158. </itemizedlist>
  159. <para>
  160. There are many ways to modify the <classname>ViewRenderer</classname>,
  161. including setting a different view script to render, specifying
  162. replacements for all replaceable elements of a view script path
  163. (including the suffix), choosing a response named segment to
  164. utilize, and more. If you aren't using the conventional modular
  165. directory structure, you can even associate different path
  166. specifications with the <classname>ViewRenderer</classname>.
  167. </para>
  168. <para>
  169. We encourage you to adapt your code to use the
  170. <classname>ErrorHandler</classname> and <classname>ViewRenderer</classname> as they are
  171. now core functionality.
  172. </para>
  173. </sect2>
  174. <sect2 id="migration.10.zend.currency">
  175. <title>Zend_Currency</title>
  176. <para>
  177. Creating an object of <classname>Zend_Currency</classname> has become simpler.
  178. You no longer have to give a script or set it to <constant>NULL</constant>. The optional
  179. script parameter is now an option which can be set through the
  180. <methodname>setFormat()</methodname> method.
  181. </para>
  182. <programlisting language="php"><![CDATA[
  183. $currency = new Zend_Currency($currency, $locale);
  184. ]]></programlisting>
  185. <para>
  186. The <methodname>setFormat()</methodname> method takes now an array of options. These
  187. options are set permanently and override all previously set values. Also a new option
  188. 'precision' has been added. The following options have been refactored:
  189. </para>
  190. <itemizedlist mark='opencircle'>
  191. <listitem>
  192. <para>
  193. <emphasis>position</emphasis>:
  194. Replacement for the old 'rules' parameter.
  195. </para>
  196. </listitem>
  197. <listitem>
  198. <para>
  199. <emphasis>script</emphasis>:
  200. Replacement for the old 'script' parameter.
  201. </para>
  202. </listitem>
  203. <listitem>
  204. <para>
  205. <emphasis>format</emphasis>:
  206. Replacement for the old 'locale' parameter which does not
  207. set new currencies but only the number format.
  208. </para>
  209. </listitem>
  210. <listitem>
  211. <para>
  212. <emphasis>display</emphasis>:
  213. Replacement for the old 'rules' parameter.
  214. </para>
  215. </listitem>
  216. <listitem>
  217. <para>
  218. <emphasis>precision</emphasis>:
  219. New parameter.
  220. </para>
  221. </listitem>
  222. <listitem>
  223. <para>
  224. <emphasis>name</emphasis>:
  225. Replacement for the ole 'rules' parameter. Sets the full
  226. currencies name.
  227. </para>
  228. </listitem>
  229. <listitem>
  230. <para>
  231. <emphasis>currency</emphasis>:
  232. New parameter.
  233. </para>
  234. </listitem>
  235. <listitem>
  236. <para>
  237. <emphasis>symbol</emphasis>:
  238. New parameter.
  239. </para>
  240. </listitem>
  241. </itemizedlist>
  242. <programlisting language="php"><![CDATA[
  243. $currency->setFormat(array $options);
  244. ]]></programlisting>
  245. <para>
  246. The <methodname>toCurrency()</methodname> method no longer supports the optional
  247. 'script' and 'locale' parameters. Instead it takes an options array which
  248. can contain the same keys as for the <methodname>setFormat()</methodname> method.
  249. </para>
  250. <programlisting language="php"><![CDATA[
  251. $currency->toCurrency($value, array $options);
  252. ]]></programlisting>
  253. <para>
  254. The methods <methodname>getSymbol()</methodname>,
  255. <methodname>getShortName()</methodname>, <methodname>getName()</methodname>,
  256. <methodname>getRegionList()</methodname> and
  257. <methodname>getCurrencyList()</methodname> are no longer static and can be called
  258. from within the object. They return the set values of the object if no
  259. parameter has been set.
  260. </para>
  261. </sect2>
  262. </sect1>
  263. <!--
  264. vim:se ts=4 sw=4 et:
  265. -->