MediaWiki REL1_41
|
Renders a diff for a single slot (that is, a diff between two content objects). More...
Inherited by DifferenceEngineSlotDiffRenderer, TextSlotDiffRenderer, and UnsupportedSlotDiffRenderer.
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. | |
getTablePrefix (IContextSource $context, Title $newTitle) | |
Get the content to add above the main diff table. | |
localizeDiff (string $diff, array $options=[]) | |
Localize language-independent text returned by getDiff(), making it suitable for display. | |
Protected Member Functions | |
normalizeContents (Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null) | |
Helper method to normalize the input of getDiff(). | |
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 43 of file SlotDiffRenderer.php.
SlotDiffRenderer::addModules | ( | OutputPage | $output | ) |
Add modules needed for correct styling/behavior of the diff.
OutputPage | $output |
Reimplemented in DifferenceEngineSlotDiffRenderer.
Definition at line 88 of file SlotDiffRenderer.php.
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.
tags, or an empty string if the inputs are identical.
IncompatibleDiffTypesException |
Reimplemented in DifferenceEngineSlotDiffRenderer, TextSlotDiffRenderer, and UnsupportedSlotDiffRenderer.
SlotDiffRenderer::getExtraCacheKeys | ( | ) |
Return any extra keys to split the diff cache by.
Reimplemented in DifferenceEngineSlotDiffRenderer, and TextSlotDiffRenderer.
Definition at line 96 of file SlotDiffRenderer.php.
SlotDiffRenderer::getTablePrefix | ( | IContextSource | $context, |
Title | $newTitle ) |
Get the content to add above the main diff table.
IContextSource | $context | |
Title | $newTitle |
Reimplemented in TextSlotDiffRenderer.
Definition at line 79 of file SlotDiffRenderer.php.
SlotDiffRenderer::localizeDiff | ( | string | $diff, |
array | $options = [] ) |
Localize language-independent text returned by getDiff(), making it suitable for display.
Subclasses overriding this should arrange for injection of a MessageLocalizer.
string | $diff | |
array | $options | Associative array of options:
|
Definition at line 66 of file SlotDiffRenderer.php.
|
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.
Content | null | &$oldContent | |
Content | null | &$newContent | |
string | array | null | $allowedClasses |
IncompatibleDiffTypesException |
Definition at line 110 of file SlotDiffRenderer.php.
Referenced by DifferenceEngineSlotDiffRenderer\getDiff(), and UnsupportedSlotDiffRenderer\getDiff().