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 );
81 private function exportSite(
Site $site ) {
83 $siteAttr = [
'type' => $site->
getType() ];
101 fwrite( $this->sink,
"\t\t" .
Xml::element(
'forward',
null,
'' ) .
"\n" );
105 fwrite( $this->sink,
"\t\t" .
Xml::element(
'path', [
'type' => $type ],
$path ) .
"\n" );
108 foreach ( $site->
getLocalIds() as $type => $ids ) {
109 foreach ( $ids as $id ) {
110 fwrite( $this->sink,
"\t\t" .
Xml::element(
'localid', [
'type' => $type ], $id ) .
"\n" );
123class_alias( SiteExporter::class,
'SiteExporter' );