/** * Registers this instance as an autoloader. * @return $this */ public function register() { // In pre-installation environments, don't bother with caching. if (!defined('CIVICRM_TEMPLATE_COMPILEDIR') || !defined('CIVICRM_DSN') || \CRM_Utils_System::isInUpgradeMode()) { return $this->buildClassLoader()->register(); } $envId = \CRM_Core_Config_Runtime::getId(); $file = CIVICRM_TEMPLATE_COMPILEDIR . "/CachedExtLoader.{$envId}.php"; if (file_exists($file)) { $loader = (require $file); } else { $loader = $this->buildClassLoader(); $ser = serialize($loader); file_put_contents($file, sprintf("<?php\nreturn unserialize(%s);", var_export($ser, 1))); } return $loader->register(); }
/** * Get a list of boot services. * * These are services which must be setup *before* the container can operate. * * @param bool $loadFromDB * @throws \CRM_Core_Exception */ public static function boot($loadFromDB) { $bootServices = array(); \Civi::$statics[__CLASS__]['boot'] =& $bootServices; $bootServices['runtime'] = array('class' => 'CRM_Core_Config_Runtime', 'obj' => $runtime = new \CRM_Core_Config_Runtime()); $runtime->initialize($loadFromDB); if ($loadFromDB && $runtime->dsn) { \CRM_Core_DAO::init($runtime->dsn); } $bootServices['paths'] = array('class' => 'Civi\\Core\\Paths', 'obj' => new \Civi\Core\Paths()); $class = $runtime->userFrameworkClass; $bootServices['userSystem'] = array('class' => 'CRM_Utils_Cache_Interface', 'obj' => $userSystem = new $class()); $userSystem->initialize(); $userPermissionClass = 'CRM_Core_Permission_' . $runtime->userFramework; $bootServices['userPermissionClass'] = array('class' => 'CRM_Core_Permission_Base', 'obj' => new $userPermissionClass()); $bootServices['cache.settings'] = array('class' => 'CRM_Utils_Cache_Interface', 'obj' => \CRM_Utils_Cache::create(array('name' => 'settings', 'type' => array('*memory*', 'SqlGroup', 'ArrayCache')))); $bootServices['settings_manager'] = array('class' => 'Civi\\Core\\SettingsManager', 'obj' => new \Civi\Core\SettingsManager($bootServices['cache.settings']['obj'])); $bootServices['lockManager'] = array('class' => 'Civi\\Core\\Lock\\LockManager', 'obj' => self::createLockManager()); if ($loadFromDB && $runtime->dsn) { \CRM_Utils_Hook::singleton(TRUE); \CRM_Extension_System::singleton(TRUE); $c = new self(); \Civi::$statics[__CLASS__]['container'] = $c->loadContainer(); } }
/** * @return string */ protected function getCacheFile() { $envId = \CRM_Core_Config_Runtime::getId(); $file = CIVICRM_TEMPLATE_COMPILEDIR . "/CachedExtLoader.{$envId}.php"; return $file; }
/** * Get a list of boot services. * * These are services which must be setup *before* the container can operate. * * @param bool $loadFromDB * @throws \CRM_Core_Exception */ public static function boot($loadFromDB) { // Array(string $serviceId => object $serviceInstance). $bootServices = array(); \Civi::$statics[__CLASS__]['boot'] =& $bootServices; $bootServices['runtime'] = $runtime = new \CRM_Core_Config_Runtime(); $runtime->initialize($loadFromDB); $bootServices['paths'] = new \Civi\Core\Paths(); $class = $runtime->userFrameworkClass; $bootServices['userSystem'] = $userSystem = new $class(); $userSystem->initialize(); $userPermissionClass = 'CRM_Core_Permission_' . $runtime->userFramework; $bootServices['userPermissionClass'] = new $userPermissionClass(); $bootServices['cache.settings'] = \CRM_Utils_Cache::create(array('name' => 'settings', 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'))); $bootServices['settings_manager'] = new \Civi\Core\SettingsManager($bootServices['cache.settings']); $bootServices['lockManager'] = self::createLockManager(); if ($loadFromDB && $runtime->dsn) { \CRM_Core_DAO::init($runtime->dsn); \CRM_Utils_Hook::singleton(TRUE); \CRM_Extension_System::singleton(TRUE); \CRM_Extension_System::singleton(TRUE)->getClassLoader()->register(); $runtime->includeCustomPath(); $c = new self(); $container = $c->loadContainer(); foreach ($bootServices as $name => $obj) { $container->set($name, $obj); } \Civi::$statics[__CLASS__]['container'] = $container; } }