:" and converts it to a class * name. It can also check that the given class is a subclass of a specific class. The * resolved classname will be "sspmod__<$type>_. * * It is also possible to specify a full classname instead of :. * * An exception will be thrown if the class can't be resolved. * * @param string $id The string we should resolve. * @param string $type The type of the class. * @param string|NULL $subclass The class should be a subclass of this class. Optional. * @return string The classname. */ public static function resolveClass($id, $type, $subclass = NULL) { assert('is_string($id)'); assert('is_string($type)'); assert('is_string($subclass) || is_null($subclass)'); $tmp = explode(':', $id, 2); if (count($tmp) === 1) { $className = $tmp[0]; } else { $className = 'sspmod_' . $tmp[0] . '_' . $type . '_' . $tmp[1]; } if (!class_exists($className)) { throw new Exception('Could not resolve \'' . $id . '\': No class named \'' . $className . '\'.'); } elseif ($subclass !== NULL && !is_subclass_of($className, $subclass)) { throw new Exception('Could not resolve \'' . $id . '\': The class \'' . $className . '\' isn\'t a subclass of \'' . $subclass . '\'.'); } return $className; } /** * Get absolute URL to a specified module resource. * * This function creates an absolute URL to a resource stored under ".../modules//www/". * * @param string $resource Resource path, on the form "/" * @return string The absolute URL to the given resource. */ public static function getModuleURL($resource) { assert('is_string($resource)'); assert('$resource[0] !== "/"'); $config = SimpleSAML_Configuration::getInstance(); return SimpleSAML_Utilities::selfURLhost() . '/' . $config->getBaseURL() . 'module.php/' . $resource; } } ?>