MediaWiki master
UnsupportedSlotDiffRenderer.php
Go to the documentation of this file.
1<?php
10namespace MediaWiki\Diff;
11
15
24
28 private $localizer;
29
30 public function __construct( MessageLocalizer $localizer ) {
31 $this->localizer = $localizer;
32 }
33
35 public function getDiff( ?Content $oldContent = null, ?Content $newContent = null ) {
36 $this->normalizeContents( $oldContent, $newContent );
37
38 $oldModel = $oldContent->getModel();
39 $newModel = $newContent->getModel();
40
41 if ( $oldModel !== $newModel ) {
42 $msg = $this->localizer->msg( 'unsupported-content-diff2', $oldModel, $newModel );
43 } else {
44 $msg = $this->localizer->msg( 'unsupported-content-diff', $oldModel );
45 }
46
47 return Html::rawElement(
48 'tr',
49 [],
50 Html::rawElement(
51 'td',
52 [ 'colspan' => 4, 'class' => 'error' ],
53 $msg->parse()
54 )
55 );
56 }
57
58}
59
61class_alias( UnsupportedSlotDiffRenderer::class, 'UnsupportedSlotDiffRenderer' );
Renders a diff for a single slot (that is, a diff between two content objects).
normalizeContents(?Content &$oldContent=null, ?Content &$newContent=null, $allowedClasses=null)
Helper method to normalize the input of getDiff().
Produces a warning message about not being able to render a slot diff.
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...
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Content objects represent page content, e.g.
Definition Content.php:28
Interface for localizing messages in MediaWiki.