Пример #1
0
 /**
  * Private function to go through plugin directory and extract
  * plugins in the system, then save them in the database
  * so that they're available for activation in admin
  *
  * @return	void
  */
 private function _process_plugins()
 {
     $configs = Swiftriver_Plugins::load_configs();
     // Sync the folder with the database
     foreach ($configs as $key => $value) {
         if (ORM::factory('Plugin')->where('plugin_path', '=', $key)->count_all() == 0) {
             $plugin = ORM::factory('Plugin');
             $plugin->plugin_path = $key;
             $plugin->plugin_name = $value['name'];
             $plugin->plugin_description = $value['description'];
             $plugin->save();
         }
     }
     // Remove Any Plugins not found in the plugins folder from the database
     foreach (ORM::factory('Plugin')->find_all() as $plugin) {
         if (!array_key_exists($plugin->plugin_path, $configs)) {
             $plugin->delete();
         }
     }
 }