From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../documentation/manual/core/en/migration.06.html | 354 +++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 zend/documentation/manual/core/en/migration.06.html (limited to 'zend/documentation/manual/core/en/migration.06.html') diff --git a/zend/documentation/manual/core/en/migration.06.html b/zend/documentation/manual/core/en/migration.06.html new file mode 100644 index 0000000..2c7a7bf --- /dev/null +++ b/zend/documentation/manual/core/en/migration.06.html @@ -0,0 +1,354 @@ + + + + + Zend Framework 0.6 - Zend Framework Manual + + + + + + + + +
+ + + + + + + + +
+ Zend Framework 0.8 + + + + +
+
+

Zend Framework 0.6

+ + +

+ When upgrading from a previous release to Zend Framework 0.6 or higher you + should note the following migration notes. +

+ +

Zend_Controller

+ + +

+ The most basic usage of the MVC components has not changed; you can + still do each of the following: +

+ +
  1. Zend_Controller_Front::run('/path/to/controllers');
+ + +
  1. /* -- create a router -- */
  2. +
  3. $router = new Zend_Controller_RewriteRouter();
  4. +
  5. $router->addRoute('user',
  6. +
  7.                   'user/:username',
  8. +
  9.                   array('controller' => 'user', 'action' => 'info')
  10. +
  11. );
  12. +
  13.  
  14. +
  15. /* -- set it in a controller -- */
  16. +
  17. $ctrl = Zend_Controller_Front::getInstance();
  18. +
  19. $ctrl->setRouter($router);
  20. +
  21.  
  22. +
  23. /* -- set controller directory and dispatch -- */
  24. +
  25. $ctrl->setControllerDirectory('/path/to/controllers');
  26. +
  27. $ctrl->dispatch();
+ + +

+ We encourage use of the Response object to aggregate content and + headers. This will allow for more flexible output format switching + (for instance, JSON or XML instead of + XHTML) in your applications. + By default, dispatch() will render the response, sending both + headers and rendering any content. You may also have the front + controller return the response using returnResponse(), + and then render the response using your own logic. A future version + of the front controller may enforce use of the response object via + output buffering. +

+ +

+ There are many additional features that extend the existing API, + and these are noted in the documentation. +

+ +

+ The main changes you will need to be aware of will be found when + subclassing the various components. Key amongst these are: +

+ +
    +
  • +

    + Zend_Controller_Front::dispatch() by default + traps exceptions in the response object, and does not render + them, in order to prevent sensitive system information from + being rendered. You can override this in several ways: +

    + +
      +
    • +

      + Set throwExceptions() in the front + controller: +

      + +
      1. $front->throwExceptions(true);
      + +
    • + +
    • +

      + Set renderExceptions() in the response + object: +

      + +
      1. $response->renderExceptions(true);
      2. +
      3. $front->setResponse($response);
      4. +
      5. $front->dispatch();
      6. +
      7.  
      8. +
      9. // or:
      10. +
      11. $front->returnResponse(true);
      12. +
      13. $response = $front->dispatch();
      14. +
      15. $response->renderExceptions(true);
      16. +
      17. echo $response;
      + +
    • +
    +
  • + +
  • +

    + Zend_Controller_Dispatcher_Interface::dispatch() + now accepts and returns a The + Request Object instead of a dispatcher token. +

    +
  • + +
  • +

    + Zend_Controller_Router_Interface::route() + now accepts and returns a The + Request Object instead of a dispatcher token. +

    +
  • + +
  • +

    Zend_Controller_Action changes include:

    + +
      +
    • +

      + The constructor now accepts exactly three arguments, + Zend_Controller_Request_Abstract + $request, + Zend_Controller_Response_Abstract + $response, + and Array $params (optional). + Zend_Controller_Action::__construct() uses + these to set the request, response, and invokeArgs + properties of the object, and if overriding the + constructor, you should do so as well. Better yet, use + the init() method to do any instance + configuration, as this method is called as the final + action of the constructor. +

      +
    • + +
    • +

      + run() is no longer defined as final, but is + also no longer used by the front controller; its sole + purpose is for using the class as a page controller. It + now takes two optional arguments, a + Zend_Controller_Request_Abstract + $request + and a Zend_Controller_Response_Abstract + $response. +

      +
    • + +
    • +

      + indexAction() no longer needs to be + defined, but is encouraged as the default action. This + allows using the RewriteRouter and action controllers to + specify different default action methods. +

      +
    • + +
    • +

      + __call() should be overridden to handle any + undefined actions automatically. +

      +
    • + +
    • +

      + _redirect() now takes an optional second + argument, the HTTP code to return with the redirect, + and an optional third argument, $prependBase, + that can indicate that the base URL registered with + the request object should be prepended to the url specified. +

      +
    • + +
    • +

      + The $_action property is no longer set. This property + was a Zend_Controller_Dispatcher_Token, + which no longer exists in the current incarnation. + The sole purpose of the token was to provide + information about the requested controller, action, + and URL parameters. This information is now + available in the request object, and can be accessed + as follows: +

      + +
      1. // Retrieve the requested controller name
      2. +
      3. // Access used to be via: $this->_action->getControllerName().
      4. +
      5. // The example below uses getRequest(), though you may also directly
      6. +
      7. // access the $_request property; using getRequest() is recommended as
      8. +
      9. // a parent class may override access to the request object.
      10. +
      11. $controller = $this->getRequest()->getControllerName();
      12. +
      13.  
      14. +
      15. // Retrieve the requested action name
      16. +
      17. // Access used to be via: $this->_action->getActionName().
      18. +
      19. $action = $this->getRequest()->getActionName();
      20. +
      21.  
      22. +
      23. // Retrieve the request parameters
      24. +
      25. // This hasn't changed; the _getParams() and _getParam() methods simply
      26. +
      27. // proxy to the request object now.
      28. +
      29. $params = $this->_getParams();
      30. +
      31. // request 'foo' parameter, using 'default' as default value if not found
      32. +
      33. $foo = $this->_getParam('foo', 'default');
      + +
    • + +
    • +

      + noRouteAction() has been removed. The + appropriate way to handle non-existent action + methods should you wish to route them to a default + action is using __call(): +

      + +
      1. public function __call($method, $args)
      2. +
      3. {
      4. +
      5.     // If an unmatched 'Action' method was requested, pass on to the
      6. +
      7.     // default action method:
      8. +
      9.     if ('Action' == substr($method, -6)) {
      10. +
      11.         return $this->defaultAction();
      12. +
      13.     }
      14. +
      15.  
      16. +
      17.     throw new Zend_Controller_Exception('Invalid method called');
      18. +
      19. }
      + +
    • +
    +
  • + +
  • +

    + Zend_Controller_RewriteRouter::setRewriteBase() has + been removed. Use Zend_Controller_Front::setBaseUrl() + instead (or Zend_Controller_Request_Http::setBaseUrl(), + if using that request class). +

    +
  • + +
  • +

    + Zend_Controller_Plugin_Interface was replaced + by Zend_Controller_Plugin_Abstract. All methods now + accept and return a The Request + Object instead of a dispatcher token. +

    +
  • +
+
+
+
+ + + + + + + + + +
+ Zend Framework 0.8 + + + + +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.3