PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Source for file dispatcher.php

Documentation is available at dispatcher.php

  1. <?php
  2. /**
  3.  *  File containing the Dispatcher class
  4.  *
  5.  *  (PHP 5)
  6.  *
  7.  *  @package PHPonTrax
  8.  *  @version $Id: dispatcher.php 245 2006-08-23 06:15:06Z john $
  9.  *  @copyright (c) 2005 John Peterson
  10.  *
  11.  *   Permission is hereby granted, free of charge, to any person obtaining
  12.  *   a copy of this software and associated documentation files (the
  13.  *   "Software"), to deal in the Software without restriction, including
  14.  *   without limitation the rights to use, copy, modify, merge, publish,
  15.  *   distribute, sublicense, and/or sell copies of the Software, and to
  16.  *   permit persons to whom the Software is furnished to do so, subject to
  17.  *   the following conditions:
  18.  *
  19.  *   The above copyright notice and this permission notice shall be
  20.  *   included in all copies or substantial portions of the Software.
  21.  *
  22.  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23.  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24.  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25.  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26.  *   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27.  *   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28.  *   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29.  */
  30.  
  31. /**
  32.  *  Singleton class to call controller selected by HTTP request
  33.  *
  34.  *  @tutorial PHPonTrax/Dispatcher.cls
  35.  */
  36. class Dispatcher {
  37.  
  38.     /**
  39.      *  Dispatch a request from Apache
  40.      *
  41.      *  Called from file dispatch.php, which is invoked by
  42.      *  {@link http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html Apache mod_rewrite}
  43.      *  whenever a client makes a request.  Actions:
  44.      *  <ol>
  45.      *    <li>Remove forbidden tags and attributes from
  46.      *      {@link http://www.php.net/reserved.variables#reserved.variables.get $_GET},
  47.      *      {@link http://www.php.net/reserved.variables#reserved.variables.post $_POST} and
  48.      *      {@link http://www.php.net/reserved.variables#reserved.variables.request $_REQUEST}.
  49. </li>
  50.      *    <li>Start a session to keep track of state between requests from
  51.      *      the client.</li>
  52.      *    <li>Construct an ActionController to process the action.</li>
  53.      *    <li>Process the route</li>
  54.      *  </ol>
  55.      *  @uses ActionController::__construct()
  56.      *  @uses ActionController::process_route()
  57.      *  @uses ActionController::process_with_exception()
  58.      *  @uses InputFilter::process_all()
  59.      *  @uses Session::start()
  60.      */
  61.     function dispatch({
  62.         try {
  63.             InputFilter::process_all();
  64.             Session::start();
  65.             $ac new ActionController();
  66.             $ac->process_route();
  67.         catch(Exception $e{
  68.             $ac->process_with_exception($e);
  69.         }
  70.     }
  71.  
  72. }
  73.  
  74. ?>

Documentation generated on Mon, 21 May 2007 22:28:28 -0600 by phpDocumentor 1.3.2