summaryrefslogtreecommitdiffstats
path: root/lib/_autoload.php
diff options
context:
space:
mode:
authorOlav Morken <olav.morken@uninett.no>2008-06-06 06:00:21 +0000
committerOlav Morken <olav.morken@uninett.no>2008-06-06 06:00:21 +0000
commit7763d0eec57ad56dc96fdb734b286a57227f1712 (patch)
tree8a75d31d7809f874ebc92ad792df8b2bd0dd5e8f /lib/_autoload.php
parent0c507ea18bf6f78f184d91ba8552ad9954cb058e (diff)
downloadsimplesamlphp-7763d0eec57ad56dc96fdb734b286a57227f1712.zip
simplesamlphp-7763d0eec57ad56dc96fdb734b286a57227f1712.tar.gz
simplesamlphp-7763d0eec57ad56dc96fdb734b286a57227f1712.tar.bz2
Add autoload support for simpleSAMLphp.
This patch adds a autoloader file (lib/_autoload.php), and changes www/_include.php to load this file. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@608 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/_autoload.php')
-rw-r--r--lib/_autoload.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/_autoload.php b/lib/_autoload.php
new file mode 100644
index 0000000..b05ee45
--- /dev/null
+++ b/lib/_autoload.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * This file implements a autoloader for simpleSAMLphp. This autoloader
+ * will search for files under the simpleSAMLphp directory.
+ *
+ * @author Olav Morken, UNINETT AS.
+ * @package simpleSAMLphp
+ * @version $Id$
+ */
+
+
+/**
+ * Autoload function for simpleSAMLphp.
+ *
+ * It will autoload all classes stored in the lib-directory.
+ *
+ * @param $className The name of the class.
+ */
+function SimpleSAML_autoload($className) {
+
+ $libDir = dirname(__FILE__) . '/';
+
+ /* Special handling for xmlseclibs.php. */
+ if(in_array($className, array('XMLSecurityKey', 'XMLSecurityDSig', 'XMLSecEnc'), TRUE)) {
+ require_once($libDir . 'xmlseclibs.php');
+ return;
+ }
+
+ $file = $libDir . str_replace('_', '/', $className) . '.php';
+ if(file_exists($file)) {
+ require_once($file);
+ }
+}
+
+/* Register autload function for simpleSAMLphp. */
+spl_autoload_register('SimpleSAML_autoload');
+
+?> \ No newline at end of file