| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\DiscussionTools\ThreadItem; |
| 4 |
|
| 5 |
use MediaWiki\Page\ProperPageIdentity; |
| 6 |
use MediaWiki\Revision\RevisionRecord; |
| 7 |
|
| 8 |
class DatabaseHeadingItem extends DatabaseThreadItem implements HeadingItem { |
| 9 |
use HeadingItemTrait; |
| 10 |
|
| 11 |
private bool $placeholderHeading; |
| 12 |
private int $headingLevel; |
| 13 |
|
| 14 |
|
| 15 |
private const PLACEHOLDER_HEADING_LEVEL = 99; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public function __construct( |
| 28 |
ProperPageIdentity $page, RevisionRecord $rev, |
| 29 |
string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level, |
| 30 |
?int $headingLevel |
| 31 |
) { |
| 32 |
parent::__construct( $page, $rev, 'heading', $name, $id, $parent, $transcludedFrom, $level ); |
| 33 |
$this->placeholderHeading = $headingLevel === null; |
| 34 |
$this->headingLevel = $this->placeholderHeading ? static::PLACEHOLDER_HEADING_LEVEL : $headingLevel; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public function getHeadingLevel(): int { |
| 41 |
return $this->headingLevel; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public function isPlaceholderHeading(): bool { |
| 48 |
return $this->placeholderHeading; |
| 49 |
} |
| 50 |
} |