Skip to content
Snippets Groups Projects
Commit 5cc42647 authored by Olav Morken's avatar Olav Morken
Browse files

Metadata sources - move parsing of sources-list to MetaDataStorageSource.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@872 44740490-163a-0410-bde0-09ae8108e29a
parent fe80b8ad
No related branches found
No related tags found
No related merge requests found
...@@ -64,19 +64,13 @@ class SimpleSAML_Metadata_MetaDataStorageHandler { ...@@ -64,19 +64,13 @@ class SimpleSAML_Metadata_MetaDataStorageHandler {
); );
} }
$this->sources = array(); try {
$this->sources = SimpleSAML_Metadata_MetaDataStorageSource::parseSources($sourcesConfig);
foreach($sourcesConfig as $elementConfig) { } catch (Exception $e) {
if(!is_array($elementConfig)) { throw new Exception('Invalid configuration of the \'metadata.sources\'' .
throw new Exception( ' configuration option: ' . $e->getMessage());
'Invalid configuration of the \'metadata.sources\' configuration option.' .
' Every element in the array should be an associative array.'
);
}
$src = SimpleSAML_Metadata_MetaDataStorageSource::getSource($elementConfig);
$this->sources[] = $src;
} }
} }
......
...@@ -15,6 +15,33 @@ ...@@ -15,6 +15,33 @@
abstract class SimpleSAML_Metadata_MetaDataStorageSource { abstract class SimpleSAML_Metadata_MetaDataStorageSource {
/**
* Parse array with metadata sources.
*
* This function accepts an array with metadata sources, and returns an array with
* each metadata source as an object.
*
* @param array $sourcesConfig Array with metadata source configuration.
* @return array Parsed metadata configuration.
*/
public static function parseSources($sourcesConfig) {
assert('is_array($sourcesConfig)');
$sources = array();
foreach ($sourcesConfig as $sourceConfig) {
if (!is_array($sourceConfig)) {
throw new Exception('Found an element in metadata source' .
' configuration which wasn\'t an array.');
}
$sources[] = self::getSource($sourceConfig);
}
return $sources;
}
/** /**
* This function creates a metadata source based on the given configuration. * This function creates a metadata source based on the given configuration.
* The type of source is based on the 'type' parameter in the configuration. * The type of source is based on the 'type' parameter in the configuration.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment