/** * @return Z_Application */ public static function getInstance() { if (Z::getGlobal('@Z.Application')) { return Z::getGlobal('@Z.Application'); } Z::setGlobal('@Z.Application', Z::createApplication(NULL)); return Z::getGlobal('@Z.Application'); }
/** * * @param unknown_type $config * @param unknown_type $class * @return Z_Application */ public static function createApplication($config = NULL, $init = NULL, $class = 'Z_Application') { if ($config == null) { $config = Z::getGlobal(Z_CONFIG); } /* * If $config is a string, a path is supplied to a php file that should * return nothing more than an array containing all Z-specific settings */ if (is_string($config)) { $config = (include $config); } if (is_array($config)) { $config = Z_Array::ToObject($config); } $config = self::_applyDefaultConfig($config); if (!class_exists($class)) { throw new Z_Exception('Application class not found: ' . $class); } Z::setGlobal(Z_CONFIG, $config); $app = new $class($config); if ($init != null) { global $application; $application = $app; include $init; $application = null; } return $app; }