9use InvalidArgumentException;
33 if ( !is_resource( $sink ) || get_resource_type( $sink ) !==
'stream' ) {
34 throw new InvalidArgumentException(
'$sink must be a file handle' );
49 'xmlns' =>
'http://www.mediawiki.org/xml/sitelist-1.0/',
54 foreach ( $sites as $site ) {
55 $this->exportSite( $site );
59 fflush( $this->sink );
65 private function exportSite(
Site $site ) {
67 $siteAttr = [
'type' => $site->
getType() ];
85 fwrite( $this->sink,
"\t\t" .
Xml::element(
'forward',
null,
'' ) .
"\n" );
89 fwrite( $this->sink,
"\t\t" .
Xml::element(
'path', [
'type' => $type ],
$path ) .
"\n" );
93 foreach ( $ids as $id ) {
94 fwrite( $this->sink,
"\t\t" .
Xml::element(
'localid', [
'type' => $type ], $id ) .
"\n" );
107class_alias( SiteExporter::class,
'SiteExporter' );