Elgg  Version 1.11
autoloader.php
Go to the documentation of this file.
1 <?php
14 function _elgg_services() {
15  static $provider;
16  if (null === $provider) {
17  $provider = _elgg_create_service_provider();
18  }
19  return $provider;
20 }
21 
33  $loader = new \Elgg\ClassLoader(new \Elgg\ClassMap());
34  // until the cache can be loaded, just setup PSR-0 autoloading
35  // out of the classes directory. No need to build a full map.
36  $loader->register();
37  $manager = new \Elgg\AutoloadManager($loader);
38 
39  return new \Elgg\Di\ServiceProvider($manager);
40 }
41 
50  $manager = _elgg_services()->autoloadManager;
51  $manager->setStorage(elgg_get_system_cache());
52  if (! $manager->loadCache()) {
53  $manager->addClasses(dirname(dirname(__FILE__)) . '/classes');
54  }
55 }
56 
63  _elgg_services()->autoloadManager->saveCache();
64 }
65 
72  _elgg_services()->autoloadManager->deleteCache();
73 }
74 
81  return _elgg_services()->autoloadManager->getLoader();
82 }
83 
96 function elgg_register_classes($dir) {
97  _elgg_services()->autoloadManager->addClasses($dir);
98 }
99 
109 function elgg_register_class($class, $location) {
110  _elgg_services()->autoloadManager->setClassPath($class, $location);
111  return true;
112 }
113 
114 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
115  $events->registerHandler('shutdown', 'system', '_elgg_save_autoload_cache', 1000);
116  $events->registerHandler('upgrade', 'all', '_elgg_delete_autoload_cache');
117 };
_elgg_load_autoload_cache()
Load cached data into the autoload system.
Definition: autoloader.php:49
elgg_get_class_loader()
Get Elgg&#39;s class loader.
Definition: autoloader.php:80
elgg_register_class($class, $location)
Register a classname to a file.
Definition: autoloader.php:109
_elgg_create_service_provider()
Sets up autoloading and creates the service provider (DIC)
Definition: autoloader.php:32
elgg_get_system_cache()
Returns an object suitable for caching system information.
Definition: cache.php:20
if(isset($vars['id'])) $class
Definition: ajax_loader.php:19
_elgg_save_autoload_cache()
Save the autoload system cache.
Definition: autoloader.php:62
Save menu items.
_elgg_services()
Definition: autoloader.php:14
_elgg_delete_autoload_cache()
Delete the autoload system cache.
Definition: autoloader.php:71
elgg_register_classes($dir)
Register a directory tree for autoloading classes/interfaces/traits.
Definition: autoloader.php:96
$loader
Definition: ajax_loader.php:32