mediawiki-extensions-Discus.../includes/HeadingItem.php
Bartosz Dziewoński 3137d76f40 Connect sub-threads to their parent threads
Our threads now also contain all replies to their sub-threads.
This is similar to how sections work in MediaWiki, where the parent
section also contains the content of all the lower-level sections.
We're going to need this for notifications about replies in a thread.

Bug: T264478
Change-Id: I241fc58e2088a7555942824b0f184ed21e3a8b6f
2020-10-22 02:05:02 +02:00

60 lines
1.4 KiB
PHP

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