function _MYMODULE_autoload in X Autoload 7.3
Same name and namespace in other branches
- 7.5 xautoload.emulate.inc \_MYMODULE_autoload()
- 7 xautoload.emulate.inc \_MYMODULE_autoload()
- 7.2 xautoload.emulate.inc \_MYMODULE_autoload()
- 7.4 xautoload.emulate.inc \_MYMODULE_autoload()
The autoload callback for this specific module, used if xautoload is not present.
You want to replace any "MYMODULE" with your module name.
Parameters
string $class: The class we want to load.
1 string reference to '_MYMODULE_autoload'
- _MYMODULE_include in ./
xautoload.emulate.inc - Register a dedicated class loader only for this module.
File
- ./
xautoload.emulate.inc, line 40 - xautoload.emulate.inc
Code
function _MYMODULE_autoload($class) {
static $lib_dir;
if (!isset($lib_dir)) {
$lib_dir = dirname(__FILE__) . '/lib/';
}
// Replace MYMODULE with your module name.
$module = 'MYMODULE';
$l = strlen($module);
if (FALSE !== ($nspos = strrpos($class, '\\'))) {
// PSR-0 mode. Omit this if you use only the PHP 5.2 compatibility mode.
if ("Drupal\\{$module}\\" === substr($class, 0, $l + 8)) {
$namespace = substr($class, 0, $nspos);
$classname = substr($class, $nspos + 1);
$path = $lib_dir . str_replace('\\', '/', $namespace) . '/' . str_replace('_', '/', $classname) . '.php';
if (is_file($path)) {
include $path;
}
}
}
else {
// PHP 5.2 compatibility mode. Omit this if you use only PSR-0.
if ($module . '_' === substr($class, 0, $l + 1)) {
$path = $lib_dir . str_replace('_', '/', $class) . '.php';
if (is_file($path)) {
include $path;
}
}
}
}