Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9 KiB

  1. <?php
  2. /**
  3. * @file include/autoloader.php
  4. */
  5. /**
  6. * @brief composer-derived autoloader init
  7. **/
  8. class FriendicaAutoloaderInit
  9. {
  10. private static $loader;
  11. public static function loadClassLoader($class)
  12. {
  13. if ('Composer\Autoload\ClassLoader' === $class) {
  14. require __DIR__ . '/autoloader/ClassLoader.php';
  15. }
  16. }
  17. public static function getLoader()
  18. {
  19. if (null !== self::$loader) {
  20. return self::$loader;
  21. }
  22. spl_autoload_register(array('FriendicaAutoloaderInit', 'loadClassLoader'), true, true);
  23. self::$loader = $loader = new \Composer\Autoload\ClassLoader();
  24. spl_autoload_unregister(array('FriendicaAutoloaderInit', 'loadClassLoader'));
  25. // library
  26. $map = require __DIR__ . '/autoloader/autoload_namespaces.php';
  27. foreach ($map as $namespace => $path) {
  28. $loader->set($namespace, $path);
  29. }
  30. $map = require __DIR__ . '/autoloader/autoload_psr4.php';
  31. foreach ($map as $namespace => $path) {
  32. $loader->setPsr4($namespace, $path);
  33. }
  34. $classMap = require __DIR__ . '/autoloader/autoload_classmap.php';
  35. if ($classMap) {
  36. $loader->addClassMap($classMap);
  37. }
  38. $loader->register(true);
  39. $includeFiles = require __DIR__ . '/autoloader/autoload_files.php';
  40. foreach ($includeFiles as $fileIdentifier => $file) {
  41. friendicaRequire($fileIdentifier, $file);
  42. }
  43. return $loader;
  44. }
  45. }
  46. function friendicaRequire($fileIdentifier, $file)
  47. {
  48. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  49. require $file;
  50. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  51. }
  52. }
  53. return FriendicaAutoloaderInit::getLoader();