Jelix\Installer\AbstractInstaller::declareDbProfile PHP Метод

declareDbProfile() защищенный Метод

declare a new db profile. if the content of the section is not given, it will declare an alias to the default profile
protected declareDbProfile ( string $name, null | string | array $sectionContent = null, boolean $force = true ) : boolean
$name string the name of the new section/alias
$sectionContent null | string | array the content of the new section, or null to create an alias.
$force boolean true:erase the existing profile
Результат boolean true if the ini file has been changed
    protected function declareDbProfile($name, $sectionContent = null, $force = true)
    {
        $profiles = new \Jelix\IniFile\IniModifier(App::configPath('profiles.ini.php'));
        if ($sectionContent == null) {
            if (!$profiles->isSection('jdb:' . $name)) {
                // no section
                if ($profiles->getValue($name, 'jdb') && !$force) {
                    // already a name
                    return false;
                }
            } else {
                if ($force) {
                    // existing section, and no content provided : we erase the section
                    // and add an alias
                    $profiles->removeValue('', 'jdb:' . $name);
                } else {
                    return false;
                }
            }
            $default = $profiles->getValue('default', 'jdb');
            if ($default) {
                $profiles->setValue($name, $default, 'jdb');
            } else {
                // default is a section
                $profiles->setValue($name, 'default', 'jdb');
            }
        } else {
            if ($profiles->getValue($name, 'jdb') !== null) {
                if (!$force) {
                    return false;
                }
                $profiles->removeValue($name, 'jdb');
            }
            if (is_array($sectionContent)) {
                foreach ($sectionContent as $k => $v) {
                    $profiles->setValue($k, $v, 'jdb:' . $name);
                }
            } else {
                $profile = $profiles->getValue($sectionContent, 'jdb');
                if ($profile !== null) {
                    $profiles->setValue($name, $profile, 'jdb');
                } else {
                    $profiles->setValue($name, $sectionContent, 'jdb');
                }
            }
        }
        $profiles->save();
        \Jelix\Core\Profiles::clear();
        return true;
    }