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

SimpleSAML_Configuration: Add getDefaultEndpoint function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1945 44740490-163a-0410-bde0-09ae8108e29a
parent 2ab14178
No related branches found
No related tags found
No related merge requests found
...@@ -944,6 +944,32 @@ class SimpleSAML_Configuration { ...@@ -944,6 +944,32 @@ class SimpleSAML_Configuration {
return $eps; return $eps;
} }
/**
* Find the default endpoint of the given type.
*
* @param string $endpointType The endpoint type.
* @param array $bindings Array with acceptable bindings. Can be NULL if any binding is allowed.
* @param mixed $default The default value to return if no matching endpoint is found. If no default is provided, an exception will be thrown.
* @return array|NULL The default endpoint, or NULL if no acceptable endpoints are used.
*/
public function getDefaultEndpoint($endpointType, array $bindings = NULL, $default = self::REQUIRED_OPTION) {
assert('is_string($endpointType)');
$endpoints = $this->getEndpoints($endpointType);
$defaultEndpoint = SimpleSAML_Utilities::getDefaultEndpoint($endpoints, $bindings);
if ($defaultEndpoint !== NULL) {
return $defaultEndpoint;
}
if ($default === self::REQUIRED_OPTION) {
$loc = $this->location . '[' . var_export($endpointType, TRUE) . ']:';
throw new Exception($loc . 'Could not find a supported ' . $endpointType . ' endpoint.');
}
return $default;
}
} }
?> ?>
\ No newline at end of file
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