Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / includes / diff / SlotDiffRenderer.php
1 <?php
2 /**
3 * Renders a diff for a single slot.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup DifferenceEngine
22 */
23
24 /**
25 * Renders a diff for a single slot (that is, a diff between two content objects).
26 *
27 * Callers should obtain this class by invoking ContentHandler::getSlotDiffRendererClass
28 * on the content handler of the new content object (ie. the one shown on the right side
29 * of the diff), or of the old one if the new one does not exist.
30 *
31 * The default implementation just does a text diff on the native text representation.
32 * Content handler extensions can subclass this to provide a more appropriate diff method by
33 * overriding ContentHandler::getSlotDiffRendererClass. Other extensions that want to interfere
34 * with diff generation in some way can use the GetSlotDiffRenderer hook.
35 *
36 * @ingroup DifferenceEngine
37 */
38 abstract class SlotDiffRenderer {
39
40 /**
41 * Get a diff between two content objects. One of them might be null (meaning a slot was
42 * created or removed), but both cannot be. $newContent (or if it's null then $oldContent)
43 * must have the same content model that was used to obtain this diff renderer.
44 * @param Content|null $oldContent
45 * @param Content|null $newContent
46 * @return string
47 */
48 abstract public function getDiff( Content $oldContent = null, Content $newContent = null );
49
50 /**
51 * Add modules needed for correct styling/behavior of the diff.
52 * @param OutputPage $output
53 */
54 public function addModules( OutputPage $output ) {
55 }
56
57 /**
58 * Return any extra keys to split the diff cache by.
59 * @return array
60 */
61 public function getExtraCacheKeys() {
62 return [];
63 }
64
65 }