23use InvalidArgumentException;
47 if ( !is_resource( $sink ) || get_resource_type( $sink ) !==
'stream' ) {
48 throw new InvalidArgumentException(
'$sink must be a file handle' );
63 'xmlns' =>
'http://www.mediawiki.org/xml/sitelist-1.0/',
68 foreach ( $sites as $site ) {
69 $this->exportSite( $site );
73 fflush( $this->sink );
79 private function exportSite(
Site $site ) {
81 $siteAttr = [
'type' => $site->
getType() ];
99 fwrite( $this->sink,
"\t\t" .
Xml::element(
'forward',
null,
'' ) .
"\n" );
103 fwrite( $this->sink,
"\t\t" .
Xml::element(
'path', [
'type' => $type ],
$path ) .
"\n" );
106 foreach ( $site->
getLocalIds() as $type => $ids ) {
107 foreach ( $ids as $id ) {
108 fwrite( $this->sink,
"\t\t" .
Xml::element(
'localid', [
'type' => $type ], $id ) .
"\n" );
121class_alias( SiteExporter::class,
'SiteExporter' );