/**
* Get a configuration file by its instance name.
*
* This function retrieves a configuration file by its instance name. The instance
* name is initialized by the init function, or by copyFromBase function.
*
* If no configuration file with the given instance name is found, an exception will
* be thrown.
*
* @param string $instancename The instance name of the configuration file. Deprecated.
*
* @return SimpleSAML_Configuration The configuration object.
*
* @throws Exception If the configuration with $instancename name is not initialized.
*/
public static function getInstance($instancename = 'simplesaml')
{
assert('is_string($instancename)');
// check if the instance exists already
if (array_key_exists($instancename, self::$instance)) {
return self::$instance[$instancename];
}
if ($instancename === 'simplesaml') {
try {
return self::getConfig();
} catch (SimpleSAML\Error\ConfigurationError $e) {
throw \SimpleSAML\Error\CriticalConfigurationError::fromException($e);
}
}
throw new \SimpleSAML\Error\CriticalConfigurationError('Configuration with name ' . $instancename . ' is not initialized.');
}