Merge ".mailmap: Correct two contributor names"
[mediawiki.git] / includes / edit / SelserContext.php
blob5933e5f0d7ed20fe6348a8b7171587301c2335eb
1 <?php
3 namespace MediaWiki\Edit;
5 use MediaWiki\Content\Content;
6 use UnexpectedValueException;
7 use Wikimedia\Parsoid\Core\PageBundle;
8 use Wikimedia\Parsoid\Core\SelserData;
10 /**
11 * Value object representing contextual information needed by Parsoid for selective serialization ("selser") of
12 * modified HTML.
14 * @see SelserData
16 * @since 1.40
18 class SelserContext {
19 private PageBundle $pageBundle;
21 private int $revId;
23 private ?Content $content;
25 /**
26 * @param PageBundle $pageBundle
27 * @param int $revId
28 * @param Content|null $content
30 public function __construct( PageBundle $pageBundle, int $revId, ?Content $content = null ) {
31 if ( !$revId && !$content ) {
32 throw new UnexpectedValueException(
33 'If $revId is 0, $content must be given. ' .
34 'If we can\'t load the content from a revision, we have to stash it.'
38 $this->pageBundle = $pageBundle;
39 $this->revId = $revId;
40 $this->content = $content;
43 /**
44 * @return PageBundle
46 public function getPageBundle(): PageBundle {
47 return $this->pageBundle;
50 /**
51 * @return int
53 public function getRevisionID(): int {
54 return $this->revId;
57 /**
58 * @return Content|null
60 public function getContent(): ?Content {
61 return $this->content;