Source for file abstract.php

Documentation is available at abstract.php

  1. <?php
  2. /**
  3.  * Abstract methods that might be redefined by user
  4.  * Do not include this file in your app: it only aims to provide documentation
  5.  * about those functions.
  6.  * 
  7.  * @package limonade
  8.  * @subpackage abstract
  9.  */
  10.  
  11. /**
  12.  * It will be called when app is launched (at the begining of the run function).
  13.  * You can define options inside it, a connection to a database ...
  14.  *
  15.  * @abstract this function might be redefined by user
  16.  * @return void 
  17.  */
  18. function configure()
  19. {
  20.   return;
  21. }
  22.  
  23. /**
  24.  * Called in run() just after session start, and before checking request method
  25.  * and output buffer start.
  26.  *
  27.  * @abstract this function might be redefined by user
  28.  * @return void 
  29.  */
  30. function initialize()
  31. {
  32.   return;
  33. }
  34.  
  35. /**
  36.  * Called in run() just after the route matching, in order to load controllers.
  37.  * If not specfied, the default function is called:
  38.  * 
  39.  * <code>
  40.  * function autoload_controller($callback)
  41.  * {
  42.  *   require_once_dir(option('controllers_dir'));
  43.  * }
  44.  * </code>
  45.  * 
  46.  *
  47.  * @param string $callback the callback defined in matching route
  48.  * @return void 
  49.  */
  50. function autoload_controller($callback)
  51. {
  52.   return;
  53. }
  54.  
  55. /**
  56.  * Called before each request.
  57.  * This is very useful to define a default layout or passing common variables
  58.  * to the templates.
  59.  *
  60.  * @abstract this function might be redefined by user
  61.  * @param array() $route array (like returned by {@link route_build()},
  62.  *    with keys "method", "pattern", "names", "callback", "options")
  63.  * @return void 
  64.  */
  65. function before($route)
  66. {
  67.   
  68. }
  69.  
  70. /**
  71.  * An `after` output filter
  72.  * 
  73.  * Called after each request and can apply a transformation to the output
  74.  * (except for `render_file` outputs  which are sent directly to the output buffer).
  75.  *
  76.  * @abstract this function might be redefined by user
  77.  * @param string $output 
  78.  * @param array() $route array (like returned by {@link route_find()},
  79.  *    with keys "method", "pattern", "names", "callback", "params", "options")
  80.  * @return string 
  81.  */
  82. function after($output$route)
  83. {
  84.   # Call functions...
  85.   # .. modifies $output...
  86.   return $output;
  87. }
  88.  
  89. /**
  90.  * Not found error output
  91.  *
  92.  * @abstract this function might be redefined by user
  93.  * @param string $errno 
  94.  * @param string $errstr 
  95.  * @param string $errfile 
  96.  * @param string $errline 
  97.  * @return string "not found" output string
  98.  */
  99. function not_found($errno$errstr$errfile=null$errline=null)
  100. {
  101.  
  102. }
  103.  
  104. /**
  105.  * Server error output
  106.  *
  107.  * @abstract this function might be redefined by user
  108.  * @param string $errno 
  109.  * @param string $errstr 
  110.  * @param string $errfile 
  111.  * @param string $errline 
  112.  * @return string "server error" output string
  113.  */
  114. function server_error($errno$errstr$errfile=null$errline=null)
  115. {
  116.   
  117. }
  118.  
  119. /**
  120.  * Called when a route is not found.
  121.  * 
  122.  * 
  123.  * @abstract this function might be redefined by user
  124.  * @param string $request_method 
  125.  * @param string $request_uri 
  126.  * @return void 
  127.  */
  128. function route_missing($request_method$request_uri)
  129. {
  130.   halt(NOT_FOUND"($request_method$request_uri")# by default
  131. }
  132.  
  133. /**
  134.  * Called before stoppping and exiting application.
  135.  *
  136.  * @abstract this function might be redefined by user
  137.  * @param boolean exit or not
  138.  * @return void 
  139.  */
  140. function before_exit($exit)
  141. {
  142.   
  143. }
  144.  
  145. /**
  146.  * Rendering prefilter.
  147.  * Useful if you want to transform your views before rendering.
  148.  * The first three parameters are the same as those provided
  149.  * to the `render` function.
  150.  *
  151.  * @abstract this function might be redefined by user
  152.  * @param string $content_or_func a function, a file in current views dir or a string
  153.  * @param string $layout 
  154.  * @param array $locals 
  155.  * @param array $view_path (by default <code>file_path(option('views_dir'),$content_or_func);</code>)
  156.  * @return array with, in order, $content_or_func, $layout, $locals vars
  157.  *   and the calculated $view_path
  158.  */
  159. function before_render($content_or_func$layout$locals$view_path)
  160. {
  161.   # transform $content_or_func, $layout, $locals or $view_path…
  162.   return array($content_or_func$layout$locals$view_path);
  163. }
  164.  
  165.  
  166. /**
  167.  * Called only if rendering $output is_null,
  168.  * like in a controller with no return statement.
  169.  *
  170.  * @abstract this function might be defined by user
  171.  * @param array() $route array (like returned by {@link route_build()},
  172.  *    with keys "method", "pattern", "names", "callback", "options")
  173.  * @return string 
  174.  */
  175. function autorender($route)
  176. {
  177.   # process output depending on $route
  178.   return $output;
  179. }

Documentation generated on Sat, 16 Oct 2010 19:09:43 +0200 by phpDocumentor 1.4.3