/**
  * register method for setting up model extensions
  *
  * @param string $model_id unique id for the extensions being setup
  * @param array   $config   {
  *               @throws EE_Error
  *               @type  array $ model_extension_paths array of folders containing DB model extensions, where each file follows the models naming convention, which is: EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and {model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base
  *               @type array $ class_extension_paths array of folders containing DB class extensions, where each file follows the model class extension naming convention, which is: EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where your_plugin_slug} is something like 'Calendar','MailChimp',etc, and model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class._{model_name_extended}.class_ext.php. Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, and {model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class.
  * }
  *
  * @return void
  */
 public static function register($model_id = NULL, $config = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($model_id) || !is_array($config) || empty($config['model_extension_paths']) && empty($config['class_extension_paths'])) {
         throw new EE_Error(__('In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', 'event_espresso'));
     }
     //check correct loading
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.3');
     }
     self::$_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['model_extension_paths']);
     }
     if (isset($config['class_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['class_extension_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
 /**
  * @param string $model_id unique id for it
  * @param array  $config   {
  *		@type array $model_paths array of folders containing DB models, where each file follows the models naming convention,
  *                         which is: EEM_{model_name}.model.php which contains a single class called EEM_{model_name}. Eg. you could pass
  *                         "public_html/wp-content/plugins/my_addon/db_models" (with or without trailing slash) and in that folder put
  *                         each of your model files, like "EEM_Food.model.php" which contains the class "EEM_Food" and
  *                         "EEM_Monkey.model.php" which contains the class "EEM_Monkey". These will be autoloaded and added to
  *                         the EE registry so they can be used like ordinary models. The class contained in each file should extend EEM_Base.
  *		@type array $class_paths array of folders containing DB classes, where each file follows the model class naming convention,
  *                         which is EE_{model_name}.class.php. The class contained in each file should extend EE_Base_Class
  *
  * }
  * @throws EE_Error
  */
 public static function register($model_id = NULL, $config = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($model_id) || !is_array($config) || empty($config['model_paths'])) {
         throw new EE_Error(__('In order to register Models with EE_Register_Model::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_paths" (an array of full server paths to folders that contain models)', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_model_registry[$model_id])) {
         return;
     }
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('FHEE__EE_System__parse_model_names') || did_action('FHEE__EE_System__parse_implemented_model_names')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.5');
     }
     self::$_model_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_paths']) && !isset($config['class_paths']) || !isset($config['model_paths']) && isset($config['class_paths'])) {
         throw new EE_Error(sprintf(__('You must register both "model_paths" AND "class_paths", not just one or the other You provided %s', 'event_espresso'), implode(", ", array_keys($config))));
     }
     if (isset($config['model_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['model_paths'])) {
             $config['model_paths'] = array($config['model_paths']);
         }
         //we want to add this as a model folder
         //and autoload them all
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         $model_name_to_classname_map = array();
         foreach (array_keys($class_to_filepath_map) as $classname) {
             $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
         }
         self::$_model_name_to_classname_map[$model_id] = $model_name_to_classname_map;
         add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_System__parse_implemented_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_Registry__load_model__paths', array('EE_Register_Model', 'add_model_folders'));
         unset($config['model_paths']);
     }
     if (isset($config['class_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['class_paths'])) {
             $config['class_paths'] = array($config['class_paths']);
         }
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         add_filter('FHEE__EE_Registry__load_class__paths', array('EE_Register_Model', 'add_class_folders'));
         unset($config['class_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         self::deregister($model_id);
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
 * Meant to add the new ee_message table to the database.
 */
//make sure we have all the stages loaded too
//unfortunately, this needs to be done upon INCLUSION of this file,
//instead of construction, because it only gets constructed on first page load
//(all other times it gets resurrected from a wordpress option)
$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
$class_to_filepath = array();
foreach ($stages as $filepath) {
    $matches = array();
    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
    $class_to_filepath[$matches[1]] = $filepath;
}
//give addons a chance to autoload their stages too
$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
EEH_Autoloader::register_autoloader($class_to_filepath);
/**
 * Class EE_DMS_Core_4_9_0
 *
 * @package            Event Espresso
 * @subpackage    core
 * @author                Mike Nelson
 * @since                4.6.0
 *
 */
class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
{
    /**
     * return EE_DMS_Core_4_9_0
     */
    public function __construct()
 /**
  * Gets all the data migration scripts available in the core folder and folders
  * in addons. Has the side effect of adding them for autoloading
  * @return array keys are expected classnames, values are their filepaths
  */
 public function get_all_data_migration_scripts_available()
 {
     if (!$this->_data_migration_class_to_filepath_map) {
         $this->_data_migration_class_to_filepath_map = array();
         foreach ($this->get_data_migration_script_folders() as $folder_path) {
             if ($folder_path[count($folder_path - 1)] != DS) {
                 $folder_path .= DS;
             }
             $files = glob($folder_path . '*.dms.php');
             if (empty($files)) {
                 continue;
             }
             foreach ($files as $file) {
                 $pos_of_last_slash = strrpos($file, DS);
                 $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1));
                 $migrates_to = $this->script_migrates_to_version($classname);
                 $slug = $migrates_to['slug'];
                 //check that the slug as contained in the DMS is associated with
                 //the slug of an addon or core
                 if ($slug != 'Core') {
                     if (!EE_Registry::instance()->get_addon_by_name($slug)) {
                         EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019');
                     }
                 }
                 $this->_data_migration_class_to_filepath_map[$classname] = $file;
             }
         }
         EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
     }
     return $this->_data_migration_class_to_filepath_map;
 }
 /**
  *    get_event_cart
  *
  * @access public
  * @param string $template
  * @return string
  * @throws \EE_Error
  */
 public function get_mini_cart($template = '')
 {
     switch ($template) {
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_list.template.php':
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_List_Line_Item_Display_Strategy';
             break;
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_table.template.php':
         default:
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_Table_Line_Item_Display_Strategy';
             break;
     }
     EEH_Autoloader::register_autoloader(array($minicart_line_item_display_strategy => EE_MER_PATH . $minicart_line_item_display_strategy . '.php'));
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('event_cart', apply_filters('FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy', $minicart_line_item_display_strategy));
     if (!$Line_Item_Display instanceof EE_Line_Item_Display && WP_DEBUG) {
         throw new EE_Error(__('A valid instance of EE_Event_Cart_Line_Item_Display_Strategy could not be obtained.', 'event_espresso'));
     }
     return $Line_Item_Display->display_line_item(EE_Registry::instance()->CART->get_grand_total());
 }