1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
<?php
namespace MediaWiki\Edit;
use MediaWiki\Content\Content;
use UnexpectedValueException;
use Wikimedia\Parsoid\Core\PageBundle;
use Wikimedia\Parsoid\Core\SelserData;
/**
* Value object representing contextual information needed by Parsoid for selective serialization ("selser") of
* modified HTML.
*
* @see SelserData
*
* @since 1.40
*/
class SelserContext {
private PageBundle $pageBundle;
private int $revId;
private ?Content $content;
/**
* @param PageBundle $pageBundle
* @param int $revId
* @param Content|null $content
*/
public function __construct( PageBundle $pageBundle, int $revId, ?Content $content = null ) {
if ( !$revId && !$content ) {
throw new UnexpectedValueException(
'If $revId is 0, $content must be given. ' .
'If we can\'t load the content from a revision, we have to stash it.'
);
}
$this->pageBundle = $pageBundle;
$this->revId = $revId;
$this->content = $content;
}
/**
* @return PageBundle
*/
public function getPageBundle(): PageBundle {
return $this->pageBundle;
}
/**
* @return int
*/
public function getRevisionID(): int {
return $this->revId;
}
/**
* @return Content|null
*/
public function getContent(): ?Content {
return $this->content;
}
}
|