PMA\setup\lib\ConfigGenerator::getServerPart PHP Method

getServerPart() protected static method

Generate server part of config file
protected static getServerPart ( PMA\libraries\config\ConfigFile $cf, string $crlf, array $servers ) : string
$cf PMA\libraries\config\ConfigFile Config file
$crlf string Carriage return char
$servers array Servers list
return string
    protected static function getServerPart(ConfigFile $cf, $crlf, $servers)
    {
        if ($cf->getServerCount() === 0) {
            return null;
        }
        $ret = "/* Servers configuration */{$crlf}\$i = 0;" . $crlf . $crlf;
        foreach ($servers as $id => $server) {
            $ret .= '/* Server: ' . strtr($cf->getServerName($id) . " [{$id}] ", '*/', '-') . "*/" . $crlf . '$i++;' . $crlf;
            foreach ($server as $k => $v) {
                $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
                $ret .= "\$cfg['Servers'][\$i]['{$k}'] = " . (is_array($v) && self::_isZeroBasedArray($v) ? self::_exportZeroBasedArray($v, $crlf) : var_export($v, true)) . ';' . $crlf;
            }
            $ret .= $crlf;
        }
        $ret .= '/* End of servers configuration */' . $crlf . $crlf;
        return $ret;
    }