mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-11 16:16:51 +00:00
0024a94ba7
Depends-On: I90656cc74bb1cb1f2f3c82ad51cfb164cb8a4a4b Bug: T296801 Change-Id: I84187b303aa10a242c872088403f808df3d1f940
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
|
|
|
|
use MediaWiki\Page\ProperPageIdentity;
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
|
|
class DatabaseHeadingItem extends DatabaseThreadItem implements HeadingItem {
|
|
use HeadingItemTrait;
|
|
|
|
/** @var bool */
|
|
private $placeholderHeading;
|
|
/** @var int */
|
|
private $headingLevel;
|
|
|
|
// Placeholder headings must have a level higher than real headings (1-6)
|
|
private const PLACEHOLDER_HEADING_LEVEL = 99;
|
|
|
|
/**
|
|
* @param ProperPageIdentity $page
|
|
* @param RevisionRecord $rev
|
|
* @param string $name
|
|
* @param string $id
|
|
* @param DatabaseThreadItem|null $parent
|
|
* @param bool|string $transcludedFrom
|
|
* @param int $level
|
|
* @param ?int $headingLevel Heading level (1-6). Use null for a placeholder heading.
|
|
*/
|
|
public function __construct(
|
|
ProperPageIdentity $page, RevisionRecord $rev,
|
|
string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level,
|
|
?int $headingLevel
|
|
) {
|
|
parent::__construct( $page, $rev, 'heading', $name, $id, $parent, $transcludedFrom, $level );
|
|
$this->placeholderHeading = $headingLevel === null;
|
|
$this->headingLevel = $this->placeholderHeading ? static::PLACEHOLDER_HEADING_LEVEL : $headingLevel;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getHeadingLevel(): int {
|
|
return $this->headingLevel;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function isPlaceholderHeading(): bool {
|
|
return $this->placeholderHeading;
|
|
}
|
|
}
|