SpecialBlock [Vue]: load extension-provided messages
[mediawiki.git] / includes / Storage / PreparedUpdate.php
blob79b6dc3191a66dc07bfce07d150d0e773e0cae93
1 <?php
2 namespace MediaWiki\Storage;
4 use MediaWiki\Content\Content;
5 use MediaWiki\Page\PageIdentity;
6 use MediaWiki\Parser\ParserOutput;
7 use MediaWiki\Revision\RenderedRevision;
8 use MediaWiki\Revision\RevisionRecord;
10 /**
11 * An object representing a page update during an edit.
13 * Instances of PreparedUpdate may be passed to hook handlers to provide them with
14 * access to the rendered version of a revision that is about to be saved, or has
15 * just been saved.
17 * MCR migration note: this replaces PreparedEdit
19 * @since 1.38
20 * @ingroup Page
22 interface PreparedUpdate {
24 /**
25 * Returns the identity of the page being updated
27 * @return PageIdentity
29 public function getPage(): PageIdentity;
31 /**
32 * Returns the content of the given slot, with no audience checks.
34 * @param string $role slot role name
36 * @return Content
37 * @throws PageUpdateException If the slot is neither set for update nor inherited from the
38 * parent revision.
40 public function getRawContent( string $role ): Content;
42 /**
43 * Whether the page will be countable after the edit.
45 * @return bool
47 public function isCountable(): bool;
49 /**
50 * Whether the page will be a redirect after the edit.
52 * @return bool
54 public function isRedirect(): bool;
56 /**
57 * Returns the update's target revision - that is, the revision that will be the current
58 * revision after the update.
60 * @return RevisionRecord
62 public function getRevision(): RevisionRecord;
64 /**
65 * Returns a RenderedRevision instance acting as a lazy holder for the ParserOutput
66 * of the revision.
68 * @return RenderedRevision
70 public function getRenderedRevision(): RenderedRevision;
72 /**
73 * Returns the role names of the slots added or updated by the new revision.
74 * Does not include the role names of slots that are being removed.
76 * @see RevisionSlotsUpdate::getModifiedRoles
78 * @return string[]
80 public function getModifiedSlotRoles(): array;
82 /**
83 * Returns the role names of the slots removed by the new revision.
85 * @return string[]
87 public function getRemovedSlotRoles(): array;
89 /**
90 * Returns the canonical parser output.
92 * Code that does not need access to the rendered HTML should use getParserOutputForMetaData()
93 * instead.
95 * @return ParserOutput
97 public function getCanonicalParserOutput(): ParserOutput;
99 /**
100 * Returns the canonical parser output without requiring rendering.
101 * It may not be safe to call getText() on the resulting ParserOutput.
103 * Code that does not need to the rendered HTML should prefer this method
104 * over getCanonicalParserOutput() since it will be significantly faster for
105 * some types of content. This would typically be the case for structured data,
106 * for which extracting data is simple, but rendering may require loading
107 * additional data.
109 * @return ParserOutput
111 public function getParserOutputForMetaData(): ParserOutput;