/** * The main entry point of the Ntentan application. This method ensures that * ntentan is properly setup for service. It takes the configuration * data as a parameter. The details of the configuration parameter are * extracted from the config file. * * @param array $ntentan The configuration data for ntentan * @param array $app The configuration data for the application */ public static function setup($ntentan, $app = false) { // setup autoloader spl_autoload_register("ntentan\\Ntentan::autoload"); $configFile = Ntentan::$configPath . 'app.ini'; if ($app === false && !file_exists($configFile)) { throw new exceptions\ApiIniFileNotFoundException("Config file *app.ini* not found"); } else { $app = $app === false ? parse_ini_file($configFile, true) : $app; } // hook in the custom exception handler set_exception_handler(array("\\ntentan\\Ntentan", "exceptionHandler")); // setup paths Ntentan::$home = $ntentan['home']; Ntentan::$namespace = $ntentan['namespace']; Ntentan::$modulesPath = isset($ntentan['modules_path']) ? $ntentan['modules_path'] : $ntentan['namespace']; Ntentan::$pluginsHome = $ntentan['plugins'] == '' ? Ntentan::$pluginsHome : $ntentan['plugins']; Ntentan::$appHome = $app['home'] == '' ? '.' : $app['home']; Ntentan::$appName = $ntentan['app']; Ntentan::$prefix = $app['prefix']; Ntentan::$context = $app['context']; Ntentan::$cacheMethod = $app[Ntentan::$context]['caching'] == '' ? Ntentan::$cacheMethod : $app[Ntentan::$context]['caching']; Ntentan::$debug = $app[Ntentan::$context]['debug'] == 'true' || $app[Ntentan::$context]['debug'] == 1 ? true : false; unset($app['home']); unset($app['plugins']); unset($app['prefix']); unset($app['context']); Ntentan::$config = $app; // setup include paths Ntentan::addIncludePath(array('lib/controllers/', 'lib/models/', 'lib/models/datastores/', 'lib/models/exceptions/', 'lib/views/', 'lib/views/template_engines/', 'lib/views/widgets/', 'lib/exceptions/', 'lib/caching/', 'lib/sessions', '/', "./", Ntentan::$namespace, Ntentan::$viewsPath, Ntentan::$pluginsHome), Ntentan::$home); // load cached items if (Cache::exists('nt_camelisations')) { Ntentan::$camelisations = Cache::get('nt_camelisations'); } else { Ntentan::$camelisations = array(); } $camelisations = count(Ntentan::$camelisations); if (!defined('STDOUT')) { sessions\Manager::start(); } }