Make XML writer support excluding opening tag in the writing process.
This commit is contained in:
parent
d438be0a72
commit
820cc7ad03
|
@ -292,10 +292,7 @@ final class Icecast extends AbstractFrontend
|
|||
}
|
||||
}
|
||||
|
||||
$configString = Writer::toString($config, 'icecast');
|
||||
|
||||
// Strip the first line (the XML charset)
|
||||
return substr($configString, strpos($configString, "\n") + 1);
|
||||
return Writer::toString($config, 'icecast', false);
|
||||
}
|
||||
|
||||
public function getCommand(Station $station): ?string
|
||||
|
|
|
@ -15,21 +15,18 @@ final class Writer
|
|||
{
|
||||
public static function toString(
|
||||
array $config,
|
||||
string $baseElement = 'xml-config'
|
||||
): string {
|
||||
return self::processConfig($config, $baseElement);
|
||||
}
|
||||
|
||||
private static function processConfig(
|
||||
array $config,
|
||||
string $baseElement = 'xml-config'
|
||||
string $baseElement = 'xml-config',
|
||||
bool $includeOpeningTag = true
|
||||
): string {
|
||||
$writer = new XMLWriter();
|
||||
$writer->openMemory();
|
||||
$writer->setIndent(true);
|
||||
$writer->setIndentString(str_repeat(' ', 4));
|
||||
|
||||
$writer->startDocument('1.0', 'UTF-8');
|
||||
if ($includeOpeningTag) {
|
||||
$writer->startDocument('1.0', 'UTF-8');
|
||||
}
|
||||
|
||||
$writer->startElement($baseElement);
|
||||
|
||||
// Make sure attributes come first
|
||||
|
|
Loading…
Reference in New Issue