Beispiel #1
0
 /**
  * Loads the configuration and plugins in the right order
  */
 static function configure()
 {
     Pie_Config::load('config/pie.json');
     // Get the app config, but don't load it yet
     $app_p = new Pie_Parameters();
     $app_p->load('config/app.json');
     $app_p->load('local/app.json');
     // Load all the plugin config files first
     $paths = explode(PS, get_include_path());
     $plugins = $app_p->get('pie', 'plugins', array());
     foreach ($plugins as $plugin) {
         $plugin_path = Pie::realPath('plugins' . DS . $plugin);
         if (!$plugin_path) {
             throw new Pie_Exception_MissingPlugin(compact('plugin'));
         }
         Pie_Config::load($plugin_path . DS . 'config' . DS . 'plugin.json');
         array_splice($paths, 1, 0, array($plugin_path));
         $PLUGIN = strtoupper($plugin);
         if (!defined($PLUGIN . '_PLUGIN_DIR')) {
             define($PLUGIN . '_PLUGIN_DIR', $plugin_path);
         }
         if (!defined($PLUGIN . '_PLUGIN_CONFIG_DIR')) {
             define($PLUGIN . '_PLUGIN_CONFIG_DIR', $plugin_path . DS . 'config');
         }
         if (!defined($PLUGIN . '_PLUGIN_CLASSES_DIR')) {
             define($PLUGIN . '_PLUGIN_CLASSES_DIR', $plugin_path . DS . 'classes');
         }
         if (!defined($PLUGIN . '_PLUGIN_FILES_DIR')) {
             define($PLUGIN . '_PLUGIN_FILES_DIR', $plugin_path . DS . 'files');
         }
         if (!defined($PLUGIN . '_PLUGIN_HANDLERS_DIR')) {
             define($PLUGIN . '_PLUGIN_HANDLERS_DIR', $plugin_path . DS . 'handlers');
         }
         if (!defined($PLUGIN . '_PLUGIN_PLUGINS_DIR')) {
             define($PLUGIN . '_PLUGIN_PLUGINS_DIR', $plugin_path . DS . 'plugins');
         }
         if (!defined($PLUGIN . '_PLUGIN_SCRIPTS_DIR')) {
             define($PLUGIN . '_PLUGIN_SCRIPTS_DIR', $plugin_path . DS . 'scripts');
         }
         if (!defined($PLUGIN . '_PLUGIN_TESTS_DIR')) {
             define($PLUGIN . '_PLUGIN_TESTS_DIR', $plugin_path . DS . 'tests');
         }
         if (!defined($PLUGIN . '_PLUGIN_WEB_DIR')) {
             define($PLUGIN . '_PLUGIN_WEB_DIR', $plugin_path . DS . 'web');
         }
     }
     set_include_path(implode(PS, $paths));
     // Now, we can merge in our app's config
     Pie_Config::merge($app_p);
     // Now, load any other files we were supposed to load
     $config_files = Pie_Config::get('pie', 'configFiles', array());
     foreach ($config_files as $cf) {
         Pie_Config::load($cf);
     }
     $script_files = Pie_Config::get('pie', 'scriptFiles', array());
     foreach ($script_files as $cf) {
         Pie::includeFile($cf);
     }
 }