/** * Sets up autoloading and creates the service provider (DIC) * * Setup global class map and loader instances and add the core classes to the map. * We can't load this from dataroot because we don't know it yet, and we'll need * several classes before we can find out! * * @throws RuntimeException * @access private */ function _elgg_create_service_provider() { // manually load classes needed for autoloading $dir = dirname(dirname(__FILE__)) . '/classes'; foreach (array('Elgg_ClassMap', 'Elgg_ClassLoader', 'Elgg_AutoloadManager') as $class) { if (!class_exists($class)) { $file = "{$dir}/" . strtr($class, '_\\', '//') . ".php"; include $file; if (!class_exists($class, false)) { throw new RuntimeException("Could not load {$class} in {$file}."); } } } $loader = new Elgg_ClassLoader(new Elgg_ClassMap()); // until the cache can be loaded, just setup PSR-0 autoloading // out of the classes directory. No need to build a full map. $loader->addFallback($dir); $loader->register(); $manager = new Elgg_AutoloadManager($loader); return new Elgg_Di_ServiceProvider($manager); }
/** * Set the state of the manager from the cache * * @return bool was the cache loaded? */ public function loadCache() { $spec = $this->getSpec(); if ($spec) { // the cached class map will have the full scanned core classes, so // don't consider the earlier mappings as "altering" the map $this->loader->getClassMap()->setMap($spec[self::KEY_CLASSES])->setAltered(false); $this->scannedDirs = $spec[self::KEY_SCANNED_DIRS]; return true; } $this->altered = true; return false; }