MediaWiki  master
DifferenceEngineSlotDiffRenderer.php
Go to the documentation of this file.
1 <?php
24 
33 
36 
38  $this->differenceEngine = clone $differenceEngine;
39 
40  // Set state to loaded. This should not matter to any of the methods invoked by
41  // the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
42  $fakeContent = MediaWikiServices::getInstance()
43  ->getContentHandlerFactory()
44  ->getContentHandler( CONTENT_MODEL_WIKITEXT )
45  ->makeEmptyContent();
46  $this->differenceEngine->setContent( $fakeContent, $fakeContent );
47 
48  $this->differenceEngine->markAsSlotDiffRenderer();
49  }
50 
52  public function getDiff( Content $oldContent = null, Content $newContent = null ) {
53  $this->normalizeContents( $oldContent, $newContent );
54  return $this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
55  }
56 
57  public function addModules( OutputPage $output ) {
58  $oldContext = null;
59  if ( $output !== $this->differenceEngine->getOutput() ) {
60  $oldContext = $this->differenceEngine->getContext();
61  $newContext = new DerivativeContext( $oldContext );
62  $newContext->setOutput( $output );
63  $this->differenceEngine->setContext( $newContext );
64  }
65  $this->differenceEngine->showDiffStyle();
66  if ( $oldContext ) {
67  $this->differenceEngine->setContext( $oldContext );
68  }
69  }
70 
71  public function getExtraCacheKeys() {
72  return $this->differenceEngine->getExtraCacheKeys();
73  }
74 
75 }
DifferenceEngineSlotDiffRenderer\$differenceEngine
DifferenceEngine $differenceEngine
Definition: DifferenceEngineSlotDiffRenderer.php:35
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
DifferenceEngine\setContent
setContent(Content $oldContent, Content $newContent)
Use specified text instead of loading from the database.
Definition: DifferenceEngine.php:1886
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:224
SlotDiffRenderer\normalizeContents
normalizeContents(Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null)
Helper method to normalize the input of getDiff().
Definition: SlotDiffRenderer.php:78
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:31
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:52
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:121
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:47
DifferenceEngineSlotDiffRenderer\addModules
addModules(OutputPage $output)
Add modules needed for correct styling/behavior of the diff.
Definition: DifferenceEngineSlotDiffRenderer.php:57
DifferenceEngineSlotDiffRenderer\getExtraCacheKeys
getExtraCacheKeys()
Return any extra keys to split the diff cache by.
Definition: DifferenceEngineSlotDiffRenderer.php:71
Content
Base interface for content objects.
Definition: Content.php:35
DifferenceEngineSlotDiffRenderer\__construct
__construct(DifferenceEngine $differenceEngine)
Definition: DifferenceEngineSlotDiffRenderer.php:37
SlotDiffRenderer
Renders a diff for a single slot (that is, a diff between two content objects).
Definition: SlotDiffRenderer.php:40
DifferenceEngine
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Definition: DifferenceEngine.php:56
DifferenceEngineSlotDiffRenderer
B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
Definition: DifferenceEngineSlotDiffRenderer.php:32