Back to Factory class

Method createConfig

protected static \Joomla\Registry\Registry
createConfig
(mixed $file, mixed $type = 'PHP', mixed $namespace = '')
Create a configuration object
Parameters
  • string $file The path to the configuration file.
  • string $type The type of the configuration file.
  • string $namespace The namespace of the configuration file.
Returns
  • \Joomla\Registry\Registry
Since
  • 1.7.0
Deprecated
  • 5.0
-
  • \Joomla\Registry\Registry
Class: Factory
Project: Joomla

Method createConfig - Source code

/**
 * Create a configuration object
 *
 * @param   string  $file       The path to the configuration file.
 * @param   string  $type       The type of the configuration file.
 * @param   string  $namespace  The namespace of the configuration file.
 *
 * @return  Registry
 *
 * @see         Registry
 * @since       1.7.0
 * @deprecated  5.0  Use the configuration object within the application.
 */
protected static function createConfig($file, $type = 'PHP', $namespace = '')
{
    @trigger_error(sprintf('%s() is deprecated. The configuration object should be read from the application.', __METHOD__), E_USER_DEPRECATED);
    if (is_file($file)) {
        include_once $file;
    }
    // Create the registry with a default namespace of config
    $registry = new Registry();
    // Sanitize the namespace.
    $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
    // Build the config name.
    $name = 'JConfig' . $namespace;
    // Handle the PHP configuration type.
    if ($type === 'PHP' && class_exists($name)) {
        // Create the JConfig object
        $config = new $name();
        // Load the configuration values into the registry
        $registry->loadObject($config);
    }
    return $registry;
}