Elgg\BootService::boot PHP Метод

boot() публичный Метод

Boots the engine
public boot ( ) : void
Результат void
    public function boot()
    {
        // Register the error handlers
        set_error_handler('_elgg_php_error_handler');
        set_exception_handler('_elgg_php_exception_handler');
        $db = _elgg_services()->db;
        // we inject the logger here to allow use of DB without loading core
        $db->setLogger(_elgg_services()->logger);
        $db->setupConnections();
        $db->assertInstalled();
        $CONFIG = _elgg_services()->config->getStorageObject();
        $local_path = Local::root()->getPath();
        // setup stuff available without any DB info
        $CONFIG->path = $local_path;
        $CONFIG->plugins_path = "{$local_path}mod/";
        $CONFIG->pluginspath = "{$local_path}mod/";
        $CONFIG->entity_types = ['group', 'object', 'site', 'user'];
        $CONFIG->language = 'en';
        // set cookie values for session and remember me
        _elgg_services()->config->getCookieConfig();
        // we need this stuff before cache
        $rows = $db->getData("\n\t\t\tSELECT *\n\t\t\tFROM {$db->prefix}config\n\t\t\tWHERE `name` IN ('__site_secret__', 'default_site', 'dataroot')\n\t\t");
        $configs = [];
        foreach ($rows as $row) {
            $configs[$row->name] = unserialize($row->value);
        }
        // booting during installation
        if (empty($configs['dataroot'])) {
            $configs['dataroot'] = '';
            // don't use cache
            $CONFIG->boot_cache_ttl = 0;
        }
        if (!$GLOBALS['_ELGG']->dataroot_in_settings) {
            $CONFIG->dataroot = rtrim($configs['dataroot'], '/\\') . DIRECTORY_SEPARATOR;
        }
        $CONFIG->site_guid = (int) $configs['default_site'];
        if (!isset($CONFIG->boot_cache_ttl)) {
            $CONFIG->boot_cache_ttl = self::DEFAULT_BOOT_CACHE_TTL;
        }
        if ($this->timer) {
            $this->timer->begin([__CLASS__ . '::getBootData']);
        }
        // early config is done, now get the core boot data
        $data = $this->getBootData($CONFIG, $db);
        if ($this->timer) {
            $this->timer->begin([__CLASS__ . '::getBootData']);
        }
        $configs_cache = $data->getConfigValues();
        $CONFIG->site = $data->getSite();
        $CONFIG->wwwroot = $CONFIG->site->url;
        $CONFIG->sitename = $CONFIG->site->name;
        $CONFIG->sitedescription = $CONFIG->site->description;
        $CONFIG->url = $CONFIG->wwwroot;
        _elgg_services()->subtypeTable->setCachedValues($data->getSubtypeData());
        foreach ($data->getConfigValues() as $key => $value) {
            $CONFIG->{$key} = $value;
        }
        _elgg_services()->plugins->setBootPlugins($data->getActivePlugins());
        _elgg_services()->pluginSettingsCache->setCachedValues($data->getPluginSettings());
        if (!$GLOBALS['_ELGG']->simplecache_enabled_in_settings) {
            $simplecache_enabled = $configs_cache['simplecache_enabled'];
            $CONFIG->simplecache_enabled = $simplecache_enabled === false ? 1 : $simplecache_enabled;
        }
        $system_cache_enabled = $configs_cache['system_cache_enabled'];
        $CONFIG->system_cache_enabled = $system_cache_enabled === false ? 1 : $system_cache_enabled;
        // needs to be set before [init, system] for links in html head
        $CONFIG->lastcache = (int) $configs_cache['simplecache_lastupdate'];
        $GLOBALS['_ELGG']->i18n_loaded_from_cache = false;
        if (!empty($CONFIG->debug)) {
            _elgg_services()->logger->setLevel($CONFIG->debug);
            _elgg_services()->logger->setDisplay(true);
        }
        _elgg_services()->views->view_path = \Elgg\Application::elggDir()->getPath("/views/");
        // finish boot sequence
        _elgg_session_boot();
        if ($CONFIG->system_cache_enabled) {
            _elgg_services()->systemCache->loadAll();
        }
        _elgg_services()->translator->loadTranslations();
        // we always need site->email and user->icontime, so load them together
        $user_guid = _elgg_services()->session->getLoggedInUserGuid();
        if ($user_guid) {
            _elgg_services()->metadataCache->populateFromEntities([$user_guid]);
        }
        // gives hint to get() how to approach missing values
        $CONFIG->site_config_loaded = true;
        // invalidate on some actions just in case other invalidation triggers miss something
        _elgg_services()->hooks->registerHandler('action', 'all', function ($action) {
            if (0 === strpos($action, 'admin/' || $action === 'plugins/settings/save')) {
                $this->invalidateCache();
            }
        }, 1);
    }