-
Notifications
You must be signed in to change notification settings - Fork 4
/
autoload.php
30 lines (27 loc) · 892 Bytes
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// Load global functions
require_once __DIR__ . '/rpow.php';
// Allow PEAR DB to find our DB driver class
// NOTE: The civix templates will also register this post-boot, but we need it pre-boot. So it goes.
set_include_path(__DIR__ . PATH_SEPARATOR . get_include_path());
/**
* Define an autoloader for Rpow.
*
* Rpow uses the namespace 'CRM_Rpow', but we need to be able
* to use it very early (pre-boot). The admin will have to
* add this classloader to the `civicrm.settings.php`.
*/
function rpow_autoload($class) {
$prefix = 'CRM_Rpow_';
$base_dir = __DIR__ . '/CRM/Rpow/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace('_', '/', $relative_class) . '.php';
if (file_exists($file)) {
require $file;
}
}
spl_autoload_register('rpow_autoload');