. */ /** * Defines an interface for creating a compiler. */ class Compiler_Factory { /** * Known compilers list. * * @var array */ protected static $_compilers = array( 'Uwa' => 'Compiler_Uwa', 'Frame' => 'Compiler_Frame', 'Google' => 'Compiler_Google', 'Live' => 'Compiler_Live', 'Opera' => 'Compiler_Desktop_Opera', 'Dashboard' => 'Compiler_Desktop_Dashboard' ); /** * Creates a compiler for the appropriate platform. * * @param string $environment * @param Widget $widget * @return Compiler A compiler for the selected platform */ public static function getCompiler($environment, Widget $widget) { if (isset(self::$_compilers[$environment])) { $class = self::$_compilers[$environment]; } else { $class = 'Compiler_' . ucfirst($environment); } try { return new $class($widget); } catch(Exception $e) { throw new Exception('Unsupported platform : ' . $environment); } } }