diff options
author | Olav Morken <olav.morken@uninett.no> | 2013-11-15 09:34:07 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2013-11-15 09:34:07 +0000 |
commit | 6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc (patch) | |
tree | f1d6c78ab5e2eec5f8b8121f9e1a838c28997fa6 /lib/_autoload_modules.php | |
parent | e9c98e008ed7dbb5d642aa4788edd2510c952ca1 (diff) | |
download | simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.zip simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.tar.gz simplesamlphp-6f61aef12c6b1b02e32da6d1c696bee6d5f1e4dc.tar.bz2 |
Start using SAML2 library from GitHub.
This patch also starts using Composer for other dependencies
(i.e. php-openid and xmlseclibs).
Thanks to Boy Baukema for implementing this!
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3290 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/_autoload_modules.php')
-rw-r--r-- | lib/_autoload_modules.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/_autoload_modules.php b/lib/_autoload_modules.php new file mode 100644 index 0000000..1ea5da0 --- /dev/null +++ b/lib/_autoload_modules.php @@ -0,0 +1,39 @@ +<?php + +/** + * This file implements a autoloader for simpleSAMLphp modules. + * + * @author Boy Baukema, SURFnet + * @package simpleSAMLphp + * @version $Id$ + */ + +/** + * Autoload function for simpleSAMLphp modules. + * + * @param string $className Name of the class. + */ +function SimpleSAML_autoload($className) +{ + $modulePrefixLength = strlen('sspmod_'); + $classPrefix = substr($className, 0, $modulePrefixLength); + if ($classPrefix !== 'sspmod_') { + return; + } + + $modNameEnd = strpos($className, '_', $modulePrefixLength); + $module = substr($className, $modulePrefixLength, $modNameEnd - $modulePrefixLength); + $moduleClass = substr($className, $modNameEnd + 1); + + if (!SimpleSAML_Module::isModuleEnabled($module)) { + return; + } + + $file = SimpleSAML_Module::getModuleDir($module) . '/lib/' . str_replace('_', '/', $moduleClass) . '.php'; + + if (file_exists($file)) { + require_once($file); + } +} + +spl_autoload_register('SimpleSAML_autoload'); |