function &addPlugin($name, $directory) { if ($this->pluginExists($name)) { show_error('PluginManager', 'Plugin with name "' . $name . '" exists already.'); } $plugin =& new Plugin($name, $directory); $pluginContext = file_exists($directory . '/plugin-context.yml') ? $directory . '/plugin-context.yml' : null; if ($pluginContext) { AppContext::load($pluginContext); } $bootstrap = file_exists($directory . '/bootstrap' . EXT) ? $directory . '/bootstrap' . EXT : null; if ($bootstrap) { include $bootstrap; } $this->plugins[$name] =& $plugin; return $plugin; }
function &loadTheme($name) { if (str_ends_with($this->themesDir, '/')) { $this->themesDir = substr($this->themesDir, 0, strlen($this->themesDir) - 1); } $themeDir = $this->themesDir . '/' . $name . '/'; if (is_dir($themeDir)) { $themeContext = file_exists($themeDir . '/theme-context.yml') ? $themeDir . '/theme-context.yml' : null; if ($themeContext) { AppContext::load($themeContext); } $bootstrap = file_exists($themeDir . '/bootstrap' . EXT) ? $themeDir . '/bootstrap' . EXT : null; if ($bootstrap) { include $bootstrap; } $theme =& new Theme($name, $themeDir); return $theme; } show_error('ThemeManager', 'Specified theme doesn\'t exist: ' . $name); }
define('EXT', '.' . pathinfo(__FILE__, PATHINFO_EXTENSION)); define('FCPATH', __FILE__); define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); define('ROOTPATH', $realpath); define('BASEPATH', $system_folder . '/'); define('APPPATH', $application_folder . '/'); //load the system require BASEPATH . 'bootstrap' . EXT; // The 3 GLOBALs $request =& new Request(); $response =& new Response(); $appContext =& new AppContext(); //starts output buffering $response->start(); //bootstrap the app if needed if (file_exists(APPPATH . 'bootstrap' . EXT)) { include APPPATH . 'bootstrap' . EXT; } //load the application AppContext::load(APPPATH . '/config/app-context.yml'); //load any plugins? - NOTE: plugins can override core behavior and add new controllers autodiscover_plugins(); //display cache after loading plugins but before calling Dispatcher if ($response->displayCache() !== TRUE) { //handle the request $dispatcher =& AppContext::createAutowiredService('Dispatcher'); $dispatcher->process(&$request, &$response); } //send the response to the browser $response->flush(); // flushs output buffering