/usr/share/php/Horde/Autoloader.php is in php-horde-autoloader 2.0.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | <?php
/**
* Horde_Autoloader
*
* Manages an application's class name to file name mapping conventions. One or
* more class-to-filename mappers are defined, and are searched in LIFO order.
*
* @author Bob Mckee <bmckee@bywires.com>
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @package Autoloader
*/
class Horde_Autoloader
{
private $_mappers = array();
private $_callbacks = array();
public function loadClass($className)
{
if ($path = $this->mapToPath($className)) {
if ($this->_include($path)) {
$className = strtolower($className);
if (isset($this->_callbacks[$className])) {
call_user_func($this->_callbacks[$className]);
}
return true;
}
}
return false;
}
public function addClassPathMapper(Horde_Autoloader_ClassPathMapper $mapper)
{
array_unshift($this->_mappers, $mapper);
return $this;
}
/**
* Add a callback to run when a class is loaded through loadClass().
*
* @param string $class The classname.
* @param mixed $callback The callback to run when the class is loaded.
*/
public function addCallback($class, $callback)
{
$this->_callbacks[strtolower($class)] = $callback;
}
public function registerAutoloader()
{
// Register the autoloader in a way to play well with as many
// configurations as possible.
spl_autoload_register(array($this, 'loadClass'));
if (function_exists('__autoload')) {
spl_autoload_register('__autoload');
}
}
/**
* Search registered mappers in LIFO order.
*/
public function mapToPath($className)
{
foreach ($this->_mappers as $mapper) {
if ($path = $mapper->mapToPath($className)) {
if ($this->_fileExists($path)) {
return $path;
}
}
}
}
protected function _include($path)
{
return (bool)include $path;
}
protected function _fileExists($path)
{
return file_exists($path);
}
}
|