function __construct(redMigratorStep $step = null) { parent::__construct($step); $class = !empty($step->class) ? $step->class : 'redMigrator'; $name = !empty($step->name) ? $step->name : ''; $xmlpath = !empty($step->xmlpath) ? $step->xmlpath : ''; JLoader::import('helpers.redmigrator', JPATH_COMPONENT_ADMINISTRATOR); redMigratorHelper::requireClass($name, $xmlpath, $class); // @@ Fix bug using PHP < 5.2.3 version $this->_conditions = call_user_func($class . '::getConditionsHook'); $db_config = array(); $db_config['driver'] = $this->params->old_dbtype; $db_config['host'] = $this->params->old_hostname; $db_config['user'] = $this->params->old_username; $db_config['password'] = $this->params->old_password; $db_config['database'] = $this->params->old_db; $db_config['prefix'] = $this->params->old_dbprefix; $this->_db_old = JDatabase::getInstance($db_config); }
/** * * @param stdClass $options Parameters to be passed to the database driver. * * @return redMigrator A redMigrator object. * * @since 3.0.0 */ static function getInstance(redMigratorStep $step = null) { $class = ''; if ($step == null) { return false; } // Correct the 3rd party extensions class name if (isset($step->element)) { $step->class = empty($step->class) ? 'redMigratorExtensions' : $step->class; } // Getting the class name if (isset($step->class)) { $class = $step->class; } // Require the correct file redMigratorHelper::requireClass($step->name, $step->xmlpath, $step->class); // If the class still doesn't exist we have nothing left to do but throw an exception. We did our best. if (!class_exists($class)) { $class = 'redMigrator'; } // Create our new redMigrator connector based on the options given. try { $instance = new $class($step); } catch (RuntimeException $e) { throw new RuntimeException(sprintf('Unable to load redMigrator object: %s', $e->getMessage())); } return $instance; }