public static getOptionalConfig ( string $filename = 'config.php', string $configSet = 'simplesaml' ) : SimpleSAML_Configuration | ||
$filename | string | The name of the configuration file. |
$configSet | string | The configuration set. Optional, defaults to 'simplesaml'. |
return | SimpleSAML_Configuration | A configuration object. |
public static function getOptionalConfig($filename = 'config.php', $configSet = 'simplesaml')
{
assert('is_string($filename)');
assert('is_string($configSet)');
if (!array_key_exists($configSet, self::$configDirs)) {
if ($configSet !== 'simplesaml') {
throw new Exception('Configuration set \'' . $configSet . '\' not initialized.');
} else {
self::$configDirs['simplesaml'] = SimpleSAML\Utils\Config::getConfigDir();
}
}
$dir = self::$configDirs[$configSet];
$filePath = $dir . '/' . $filename;
return self::loadFromFile($filePath, false);
}
/** * Determine whether a module is enabled. * * Will return false if the given module doesn't exists. * * @param string $module Name of the module * * @return bool True if the given module is enabled, false otherwise. * * @throws Exception If module.enable is set and is not boolean. */ public static function isModuleEnabled($module) { $moduleDir = self::getModuleDir($module); if (!is_dir($moduleDir)) { return false; } $globalConfig = SimpleSAML_Configuration::getOptionalConfig(); $moduleEnable = $globalConfig->getArray('module.enable', array()); if (isset($moduleEnable[$module])) { if (is_bool($moduleEnable[$module]) === true) { return $moduleEnable[$module]; } throw new Exception("Invalid module.enable value for for the module {$module}"); } if (assert_options(ASSERT_ACTIVE) && !file_exists($moduleDir . '/default-enable') && !file_exists($moduleDir . '/default-disable')) { SimpleSAML_Logger::error("Missing default-enable or default-disable file for the module {$module}"); } if (file_exists($moduleDir . '/enable')) { return true; } if (!file_exists($moduleDir . '/disable') && file_exists($moduleDir . '/default-enable')) { return true; } return false; }