Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace PhpOffice\PhpWord;
- /**
- * Custom Autoloader for PHPWord
- */
- class Autoloader
- {
- const BASE_DIR = __DIR__;
- /**
- * Register the autoloader
- */
- public static function register()
- {
- spl_autoload_register([new self, 'autoload']);
- }
- /**
- * Autoload function
- */
- public static function autoload($class)
- {
- $prefix = "PhpOffice\\PhpWord\\";
- $baseDir = self::BASE_DIR . DIRECTORY_SEPARATOR;
- if (strpos($class, $prefix) !== 0) {
- return false;
- }
- $relativeClass = substr($class, strlen($prefix));
- $file = $baseDir . str_replace("\\", DIRECTORY_SEPARATOR, $relativeClass) . ".php";
- if (file_exists($file)) {
- require_once $file;
- } else {
- die("Class $class not found in $file");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement