Orion PHP  0.11.12
The PHP5.3 framework
renderer.php
Go to the documentation of this file.
00001 <?php
00002 
00003 namespace Orion\Core;
00004 
00005 
00006 /**
00007  * \Orion\Core\Renderer
00008  * 
00009  * Orion Renderer manager class.
00010  *
00011  * @author Thibaut Despoulain
00012  * @license BSD 4-clauses
00013  * @version 0.11.12
00014  *
00015  * @static
00016  */
00017 class Renderer
00018 {
00019     /**
00020      * Template renderers flags
00021      */
00022     const SMARTY = 'smarty';
00023 
00024     const DEFAULT_RENDERER = 'smarty';
00025 
00026     /**
00027      * Current renderer's instance
00028      * @var TemplateRenderer
00029      */
00030     public static $CURRENT = null;
00031 
00032     /**
00033      * Set the current renderer to $template (Smarty by default)
00034      * @param string $template Template renderer's name
00035      * @return TemplateRenderer (A smarty instance by default)
00036      */
00037     public static function setRenderer( $renderer )
00038     {
00039         $file = Context::$PATH . \Orion::RENDERER_PATH . $renderer . '.php';
00040         $class = '\Orion\\Renderers\\' . ucfirst( $renderer );
00041 
00042         if ( !file_exists( $file ) )
00043             throw new Exception( 'Renderer class does not exist.', E_USER_ERROR, self::CLASS_NAME );
00044 
00045         require_once($file);
00046         self::$CURRENT = new $class();
00047 
00048         return self::$CURRENT;
00049     }
00050 
00051 }
00052 
00053 ?>