mediawiki-extensions-Discus.../includes/HeadingItem.php
Ed Sanders 2a03b6e420 Add JSON serialize methods
Change-Id: Iaa24c39842cbe76370aaeba01eab2c991d290b8c
2020-09-23 20:35:57 +01:00

42 lines
971 B
PHP

<?php
namespace MediaWiki\Extension\DiscussionTools;
class HeadingItem extends ThreadItem {
private $placeholderHeading = false;
/**
* @param ImmutableRange $range
* @param bool $placeholderHeading Item doesn't correspond to a real heading (e.g. 0th section)
*/
public function __construct(
ImmutableRange $range, bool $placeholderHeading = false
) {
parent::__construct( 'heading', 0, $range );
$this->placeholderHeading = $placeholderHeading;
}
/**
* @return array JSON-serializable array
*/
public function jsonSerialize() : array {
return array_merge( parent::jsonSerialize(), [
'placeholderHeading' => $this->placeholderHeading,
] );
}
/**
* @return bool
*/
public function isPlaceholderHeading() : bool {
return $this->placeholderHeading;
}
/**
* @param bool $placeholderHeading
*/
public function setPlaceholderHeading( bool $placeholderHeading ) : void {
$this->placeholderHeading = $placeholderHeading;
}
}