Elgg\Config::loadSettingsFile PHP Method

loadSettingsFile() public method

public loadSettingsFile ( )
    public function loadSettingsFile()
    {
        if ($this->settings_loaded) {
            return;
        }
        if (isset($this->config->Config_file)) {
            if ($this->config->Config_file === false) {
                $this->settings_loaded = true;
                return;
            }
            $path = $this->config->Config_file;
        } else {
            $path = Directory\Local::root()->getPath('engine/settings.php');
            if (!is_file($path)) {
                $path = Directory\Local::root()->getPath('elgg-config/settings.php');
            }
        }
        // No settings means a fresh install
        if (!is_file($path)) {
            if ($this->getVolatile('installer_running')) {
                $this->settings_loaded = true;
                return;
            }
            header("Location: install.php");
            exit;
        }
        if (!is_readable($path)) {
            echo "The Elgg settings file exists but the web server doesn't have read permission to it.";
            exit;
        }
        // we assume settings is going to write to CONFIG, but we may need to copy its values
        // into our local config
        global $CONFIG;
        $global_is_bound = isset($CONFIG) && $CONFIG === $this->config;
        require_once $path;
        // normalize commonly needed values
        if (isset($CONFIG->dataroot)) {
            $CONFIG->dataroot = rtrim($CONFIG->dataroot, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            $GLOBALS['_ELGG']->dataroot_in_settings = true;
        } else {
            $GLOBALS['_ELGG']->dataroot_in_settings = false;
        }
        $GLOBALS['_ELGG']->simplecache_enabled_in_settings = isset($CONFIG->simplecache_enabled);
        if (!empty($CONFIG->cacheroot)) {
            $CONFIG->cacheroot = rtrim($CONFIG->cacheroot, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        }
        if (!$global_is_bound) {
            // must manually copy settings into our storage
            foreach ($CONFIG as $key => $value) {
                $this->config->{$key} = $value;
            }
        }
        $this->settings_loaded = true;
    }