MediaWiki REL1_34
SlotDiffRenderer Class Reference

Renders a diff for a single slot (that is, a diff between two content objects). More...

Inheritance diagram for SlotDiffRenderer:

Public Member Functions

 addModules (OutputPage $output)
 Add modules needed for correct styling/behavior of the diff.
 
 getDiff (Content $oldContent=null, Content $newContent=null)
 Get a diff between two content objects.
 
 getExtraCacheKeys ()
 Return any extra keys to split the diff cache by.
 

Protected Member Functions

 normalizeContents (Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null)
 Helper method to normalize the input of getDiff().
 

Detailed Description

Renders a diff for a single slot (that is, a diff between two content objects).

Callers should obtain instances of this class by invoking ContentHandler::getSlotDiffRenderer on the content handler of the new content object (ie. the one shown on the right side of the diff), or of the old one if the new one does not exist.

The default implementation just does a text diff on the native text representation. Content handler extensions can subclass this to provide a more appropriate diff method by overriding ContentHandler::getSlotDiffRendererInternal. Other extensions that want to interfere with diff generation in some way can use the GetSlotDiffRenderer hook.

Definition at line 39 of file SlotDiffRenderer.php.

Member Function Documentation

◆ addModules()

SlotDiffRenderer::addModules ( OutputPage  $output)

Add modules needed for correct styling/behavior of the diff.

Parameters
OutputPage$output

Reimplemented in DifferenceEngineSlotDiffRenderer.

Definition at line 55 of file SlotDiffRenderer.php.

◆ getDiff()

SlotDiffRenderer::getDiff ( Content  $oldContent = null,
Content  $newContent = null 
)
abstract

Get a diff between two content objects.

One of them might be null (meaning a slot was created or removed), but both cannot be. $newContent (or if it's null then $oldContent) must have the same content model that was used to obtain this diff renderer.

Parameters
Content | null$oldContent
Content | null$newContent
Returns
string HTML, one or more

tags.

Reimplemented in DifferenceEngineSlotDiffRenderer, TextSlotDiffRenderer, and UnsupportedSlotDiffRenderer.

◆ getExtraCacheKeys()

SlotDiffRenderer::getExtraCacheKeys ( )

Return any extra keys to split the diff cache by.

Returns
array

Reimplemented in DifferenceEngineSlotDiffRenderer.

Definition at line 62 of file SlotDiffRenderer.php.

◆ normalizeContents()

SlotDiffRenderer::normalizeContents ( Content $oldContent = null,
Content $newContent = null,
  $allowedClasses = null 
)
protected

Helper method to normalize the input of getDiff().

Verifies that at least one of $oldContent and $newContent is not null, verifies that they are instances of one of the allowed classes (if provided), and replaces null with empty content.

Parameters
Content | null&$oldContent
Content | null&$newContent
string | array | null$allowedClasses

Definition at line 75 of file SlotDiffRenderer.php.

Referenced by DifferenceEngineSlotDiffRenderer\getDiff(), TextSlotDiffRenderer\getDiff(), and UnsupportedSlotDiffRenderer\getDiff().


The documentation for this class was generated from the following file: