MediaWiki
master
Toggle main menu visibility
DifferenceEngineSlotDiffRenderer.php
Go to the documentation of this file.
1
<?php
9
10
namespace
MediaWiki\Diff;
11
12
use MediaWiki\Content\Content;
13
use MediaWiki\Context\DerivativeContext;
14
use MediaWiki\MediaWikiServices;
15
use MediaWiki\Output\OutputPage;
16
24
class
DifferenceEngineSlotDiffRenderer
extends
SlotDiffRenderer
{
25
27
private
$differenceEngine;
28
29
public
function
__construct
(
DifferenceEngine
$differenceEngine ) {
30
$this->differenceEngine = clone $differenceEngine;
31
32
// Set state to loaded. This should not matter to any of the methods invoked by
33
// the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
34
$fakeContent =
MediaWikiServices::getInstance
()
35
->getContentHandlerFactory()
36
->getContentHandler(
CONTENT_MODEL_WIKITEXT
)
37
->makeEmptyContent();
38
$this->differenceEngine->setContent( $fakeContent, $fakeContent );
39
40
$this->differenceEngine->markAsSlotDiffRenderer();
41
}
42
44
public
function
getDiff
( ?
Content
$oldContent =
null
, ?
Content
$newContent =
null
) {
45
$this->
normalizeContents
( $oldContent, $newContent );
46
return
$this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
47
}
48
50
public
function
addModules
(
OutputPage
$output ) {
51
$oldContext =
null
;
52
if
( $output !== $this->differenceEngine->
getOutput
() ) {
53
$oldContext = $this->differenceEngine->getContext();
54
$newContext =
new
DerivativeContext
( $oldContext );
55
$newContext->setOutput( $output );
56
$this->differenceEngine->setContext( $newContext );
57
}
58
$this->differenceEngine->showDiffStyle();
59
if
( $oldContext ) {
60
$this->differenceEngine->setContext( $oldContext );
61
}
62
}
63
65
public
function
getExtraCacheKeys
() {
66
return
$this->differenceEngine->getExtraCacheKeys();
67
}
68
69
}
70
72
class_alias( DifferenceEngineSlotDiffRenderer::class,
'DifferenceEngineSlotDiffRenderer'
);
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition
Defines.php:235
MediaWiki\Context\ContextSource\getOutput
getOutput()
Definition
ContextSource.php:138
MediaWiki\Context\DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition
DerivativeContext.php:35
MediaWiki\Diff\DifferenceEngineSlotDiffRenderer
B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
Definition
DifferenceEngineSlotDiffRenderer.php:24
MediaWiki\Diff\DifferenceEngineSlotDiffRenderer\getExtraCacheKeys
getExtraCacheKeys()
Return any extra keys to split the diff cache by.to override string[]
Definition
DifferenceEngineSlotDiffRenderer.php:65
MediaWiki\Diff\DifferenceEngineSlotDiffRenderer\getDiff
getDiff(?Content $oldContent=null, ?Content $newContent=null)
Get a diff between two content objects.One of them might be null (meaning a slot was created or remov...
Definition
DifferenceEngineSlotDiffRenderer.php:44
MediaWiki\Diff\DifferenceEngineSlotDiffRenderer\addModules
addModules(OutputPage $output)
Add modules needed for correct styling/behavior of the diff.to override
Definition
DifferenceEngineSlotDiffRenderer.php:50
MediaWiki\Diff\DifferenceEngineSlotDiffRenderer\__construct
__construct(DifferenceEngine $differenceEngine)
Definition
DifferenceEngineSlotDiffRenderer.php:29
MediaWiki\Diff\DifferenceEngine
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Definition
DifferenceEngine.php:82
MediaWiki\Diff\SlotDiffRenderer
Renders a diff for a single slot (that is, a diff between two content objects).
Definition
SlotDiffRenderer.php:34
MediaWiki\Diff\SlotDiffRenderer\normalizeContents
normalizeContents(?Content &$oldContent=null, ?Content &$newContent=null, $allowedClasses=null)
Helper method to normalize the input of getDiff().
Definition
SlotDiffRenderer.php:101
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition
MediaWikiServices.php:361
MediaWiki\Output\OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition
OutputPage.php:84
MediaWiki\Content\Content
Content objects represent page content, e.g.
Definition
Content.php:28
includes
Diff
DifferenceEngineSlotDiffRenderer.php
Generated on
for MediaWiki by
1.18.0