2014-03-22 10:06:08 +04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-03-26 16:33:20 +07:00
|
|
|
* PHPWord
|
2014-03-22 10:06:08 +04:00
|
|
|
*
|
2014-03-27 23:55:06 +07:00
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
|
|
|
|
* @copyright 2014 PHPWord
|
2014-05-04 17:55:54 +07:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL
|
2014-03-22 10:06:08 +04:00
|
|
|
*/
|
|
|
|
|
|
2014-03-22 15:32:02 +04:00
|
|
|
namespace PhpOffice\PhpWord;
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Autoloader
|
|
|
|
|
*/
|
2014-03-22 10:06:08 +04:00
|
|
|
class Autoloader
|
|
|
|
|
{
|
|
|
|
|
const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\';
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-24 00:26:10 +07:00
|
|
|
* Register
|
|
|
|
|
*
|
2014-03-22 10:06:08 +04:00
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public static function register()
|
|
|
|
|
{
|
2014-03-23 12:07:29 -04:00
|
|
|
spl_autoload_register(array(new self, 'autoload'));
|
2014-03-22 10:06:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-24 00:26:10 +07:00
|
|
|
* Autoload
|
|
|
|
|
*
|
2014-03-23 12:07:29 -04:00
|
|
|
* @param string $class
|
2014-03-22 10:06:08 +04:00
|
|
|
*/
|
2014-03-23 12:07:29 -04:00
|
|
|
public static function autoload($class)
|
2014-03-22 10:06:08 +04:00
|
|
|
{
|
2014-03-23 12:07:29 -04:00
|
|
|
$prefixLength = strlen(self::NAMESPACE_PREFIX);
|
|
|
|
|
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
|
|
|
|
|
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength));
|
|
|
|
|
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
|
|
|
|
|
if (file_exists($file)) {
|
|
|
|
|
require_once $file;
|
2014-03-22 10:06:08 +04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-24 00:26:10 +07:00
|
|
|
}
|