SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataCurrentEntityID PHP Method

getMetaDataCurrentEntityID() public method

It will throw an exception if it is unable to locate the entity id.
public getMetaDataCurrentEntityID ( string $set, string $type = 'entityid' ) : string
$set string The set we look for the entity id in.
$type string Do you want to return the metaindex or the entityID. [entityid|metaindex]
return string The entity id which is associated with the current hostname/path combination.
    public function getMetaDataCurrentEntityID($set, $type = 'entityid')
    {
        assert('is_string($set)');
        // first we look for the hostname/path combination
        $currenthostwithpath = \SimpleSAML\Utils\HTTP::getSelfHostWithPath();
        // sp.example.org/university
        foreach ($this->sources as $source) {
            $index = $source->getEntityIdFromHostPath($currenthostwithpath, $set, $type);
            if ($index !== null) {
                return $index;
            }
        }
        // then we look for the hostname
        $currenthost = \SimpleSAML\Utils\HTTP::getSelfHost();
        // sp.example.org
        foreach ($this->sources as $source) {
            $index = $source->getEntityIdFromHostPath($currenthost, $set, $type);
            if ($index !== null) {
                return $index;
            }
        }
        // then we look for the DEFAULT entry
        foreach ($this->sources as $source) {
            $entityId = $source->getEntityIdFromHostPath('__DEFAULT__', $set, $type);
            if ($entityId !== null) {
                return $entityId;
            }
        }
        // we were unable to find the hostname/path in any metadata source
        throw new Exception('Could not find any default metadata entities in set [' . $set . '] for host [' . $currenthost . ' : ' . $currenthostwithpath . ']');
    }