3 * Base class for output stream; prints to stdout or buffer or wherever.
5 * Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org>
6 * https://www.mediawiki.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
29 class DumpMultiWriter
{
38 public function __construct( $sinks ) {
39 $this->sinks
= $sinks;
40 $this->count
= count( $sinks );
44 * @param string $string
46 public function writeOpenStream( $string ) {
47 for ( $i = 0; $i < $this->count
; $i++
) {
48 $this->sinks
[$i]->writeOpenStream( $string );
53 * @param string $string
55 public function writeCloseStream( $string ) {
56 for ( $i = 0; $i < $this->count
; $i++
) {
57 $this->sinks
[$i]->writeCloseStream( $string );
62 * @param stdClass $page
63 * @param string $string
65 public function writeOpenPage( $page, $string ) {
66 for ( $i = 0; $i < $this->count
; $i++
) {
67 $this->sinks
[$i]->writeOpenPage( $page, $string );
72 * @param string $string
74 public function writeClosePage( $string ) {
75 for ( $i = 0; $i < $this->count
; $i++
) {
76 $this->sinks
[$i]->writeClosePage( $string );
81 * @param stdClass $rev
82 * @param string $string
84 public function writeRevision( $rev, $string ) {
85 for ( $i = 0; $i < $this->count
; $i++
) {
86 $this->sinks
[$i]->writeRevision( $rev, $string );
91 * @param array $newnames
93 public function closeRenameAndReopen( $newnames ) {
94 $this->closeAndRename( $newnames, true );
98 * @param array $newnames
101 public function closeAndRename( $newnames, $open = false ) {
102 for ( $i = 0; $i < $this->count
; $i++
) {
103 $this->sinks
[$i]->closeAndRename( $newnames[$i], $open );
110 public function getFilenames() {
112 for ( $i = 0; $i < $this->count
; $i++
) {
113 $filenames[] = $this->sinks
[$i]->getFilenames();