mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-28 02:00:57 +00:00
880f9755e0
Rename ThreadItem to ContentThreadItem, then create a new ThreadItem interface containing only the methods that we'll be able to implement using only the persistently stored data (no parsing), then create a DatabaseThreadItem. Do the same for CommentItem and HeadingItem. ThreadItemSet gets a similar treatment, but it's basically only for Phan's type checking. (This is sad.) Change-Id: I1633049befe8ec169753b82eb876459af1f63fe8
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
|
|
|
|
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 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(
|
|
string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level,
|
|
?int $headingLevel
|
|
) {
|
|
parent::__construct( '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;
|
|
}
|
|
}
|