ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Autoloader.php
Go to the documentation of this file.
1<?php
2
3namespace Complex;
4
14{
19 public static function Register()
20 {
21 if (function_exists('__autoload')) {
22 // Register any existing autoloader function with SPL, so we don't get any clashes
23 spl_autoload_register('__autoload');
24 }
25 // Register ourselves with SPL
26 return spl_autoload_register(['Complex\\Autoloader', 'Load']);
27 }
28
29
35 public static function Load($pClassName)
36 {
37 if ((class_exists($pClassName, false)) || (strpos($pClassName, 'Complex\\') !== 0)) {
38 // Either already loaded, or not a Complex class request
39 return false;
40 }
41
42 $pClassFilePath = __DIR__ . DIRECTORY_SEPARATOR .
43 'src' . DIRECTORY_SEPARATOR .
44 str_replace(['Complex\\', '\\'], ['', '/'], $pClassName) .
45 '.php';
46
47 if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
48 // Can't load
49 return false;
50 }
51 require($pClassFilePath);
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
static Load($pClassName)
Autoload a class identified by name.
Definition: Autoloader.php:35
static Register()
Register the Autoloader with SPL.
Definition: Autoloader.php:19