Remove HWLDFWordAccumulator, deprecated in 1.28
[lhc/web/wiklou.git] / includes / diff / DifferenceEngineSlotDiffRenderer.php
1 <?php
2 /**
3 * Adapter for turning a DifferenceEngine into a SlotDiffRenderer.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup DifferenceEngine
22 */
23
24 /**
25 * B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
26 * Before SlotDiffRenderer was introduced, getDiff() functionality was provided by DifferenceEngine
27 * subclasses. Convert such a subclass into a SlotDiffRenderer.
28 * @deprecated
29 * @ingroup DifferenceEngine
30 */
31 class DifferenceEngineSlotDiffRenderer extends SlotDiffRenderer {
32
33 /** @var DifferenceEngine */
34 private $differenceEngine;
35
36 public function __construct( DifferenceEngine $differenceEngine ) {
37 $this->differenceEngine = clone $differenceEngine;
38
39 // Set state to loaded. This should not matter to any of the methods invoked by
40 // the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
41 $fakeContent = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT )->makeEmptyContent();
42 $this->differenceEngine->setContent( $fakeContent, $fakeContent );
43
44 $this->differenceEngine->markAsSlotDiffRenderer();
45 }
46
47 /** @inheritDoc */
48 public function getDiff( Content $oldContent = null, Content $newContent = null ) {
49 $this->normalizeContents( $oldContent, $newContent );
50 return $this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
51 }
52
53 public function addModules( OutputPage $output ) {
54 $oldContext = null;
55 if ( $output !== $this->differenceEngine->getOutput() ) {
56 $oldContext = $this->differenceEngine->getContext();
57 $newContext = new DerivativeContext( $oldContext );
58 $newContext->setOutput( $output );
59 $this->differenceEngine->setContext( $newContext );
60 }
61 $this->differenceEngine->showDiffStyle();
62 if ( $oldContext ) {
63 $this->differenceEngine->setContext( $oldContext );
64 }
65 }
66
67 public function getExtraCacheKeys() {
68 return $this->differenceEngine->getExtraCacheKeys();
69 }
70
71 }