/** * Base setup. * * @return void */ public static function register() { spl_autoload_register(array('ZLoader', 'autoload')); self::$autoloaders = new UniversalClassLoader(); self::$autoloaders->register(); $mapClassLoader = new \Symfony\Component\ClassLoader\MapClassLoader(self::map()); $mapClassLoader->register(); self::$moduleLoader = new \Zikula\Framework\ModuleClassLoader(); self::$moduleLoader->spl_autoload_register(); }
private function _buildTemporaryClassLoader() { if (!class_exists('Symfony\\Component\\ClassLoader\\MapClassLoader', false)) { require TUBEPRESS_ROOT . '/vendor/symfony/class-loader/MapClassLoader.php'; } /** * Create a temporary classloader so we can do the full boot. */ /** @noinspection PhpIncludeInspection */ $fullClassMap = (require TUBEPRESS_ROOT . '/src/php/scripts/classloading/classmap.php'); $this->_temporaryClassLoader = new \Symfony\Component\ClassLoader\MapClassLoader($fullClassMap); $this->_temporaryClassLoader->register(); }
private function _setupClassLoader(array $addons) { $addonClassMap = $this->_getClassMapFromAddons($addons); $fullClassMap = (require TUBEPRESS_ROOT . '/src/php/scripts/classloading/classmap.php'); $finalClassMap = array_merge($fullClassMap, $addonClassMap); $this->_mapClassLoader = new \Symfony\Component\ClassLoader\MapClassLoader($finalClassMap); $systemCachePath = $this->_bootSettings->getPathToSystemCacheDirectory(); $dumpPath = $systemCachePath . DIRECTORY_SEPARATOR . 'classmap.php'; $exportedClassMap = var_export($finalClassMap, true); $toDump = sprintf('<?php return %s;', $exportedClassMap); if ($this->_shouldLog) { $this->_logDebug(sprintf('Our final classmap has <code>%d</code> classes in it. We\'ll try to dump it to <code>%s</code>.', count($finalClassMap), $dumpPath)); } $this->_mapClassLoader->register(); $result = @file_put_contents($dumpPath, $toDump); if ($this->_shouldLog) { if ($result !== false) { $msg = sprintf('Successfully wrote <code>%d</code> bytes to <code>%s</code>', $result, $dumpPath); } else { $msg = sprintf('Unable to write to <code>%s</code>', $dumpPath); } $this->_logDebug($msg); } }
private function _06_registerClassLoaderIfRequested() { if (!$this->_bootSettings->isClassLoaderEnabled()) { return; } $expectedPath = $this->_bootSettings->getPathToSystemCacheDirectory() . DIRECTORY_SEPARATOR . 'classmap.php'; $debugEnabled = $this->_bootLogger->isEnabled(); if ($debugEnabled) { $this->_logDebug(sprintf('Attempting to include classmap from <code>%s</code>', $expectedPath)); } if (!is_readable($expectedPath)) { if ($debugEnabled) { $this->_logDebug(sprintf('<code>%s</code> is not readable. That\'s not great.', $expectedPath)); } return; } if ($debugEnabled) { $this->_logDebug(sprintf('<code>%s</code> is readable.', $expectedPath)); } if (!class_exists('Symfony\\Component\\ClassLoader\\MapClassLoader', false)) { require TUBEPRESS_ROOT . '/vendor/symfony/class-loader/MapClassLoader.php'; } $classMap = (require $expectedPath); $mapClassLoader = new \Symfony\Component\ClassLoader\MapClassLoader($classMap); $mapClassLoader->register(); if ($debugEnabled) { $this->_logDebug(sprintf('Successfully loaded a map of <code>%d</code> classes from <code>%s</code>.', count($classMap), $expectedPath)); } }