| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\DiscussionTools\ThreadItem; |
| 4 |
|
| 5 |
trait HeadingItemTrait { |
| 6 |
|
| 7 |
|
| 8 |
abstract public function getName(): string; |
| 9 |
|
| 10 |
abstract public function getHeadingLevel(): int; |
| 11 |
abstract public function isPlaceholderHeading(): bool; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public function jsonSerialize( bool $deep = false, ?callable $callback = null ): array { |
| 19 |
return array_merge( [ |
| 20 |
'headingLevel' => $this->isPlaceholderHeading() ? null : $this->getHeadingLevel(), |
| 21 |
|
| 22 |
|
| 23 |
'name' => $this->getName(), |
| 24 |
], parent::jsonSerialize( $deep, $callback ) ); |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function isSubscribable(): bool { |
| 31 |
return ( |
| 32 |
|
| 33 |
!$this->isPlaceholderHeading() && |
| 34 |
|
| 35 |
|
| 36 |
$this->getHeadingLevel() === 2 && |
| 37 |
|
| 38 |
|
| 39 |
$this->getName() !== 'h-' |
| 40 |
); |
| 41 |
} |
| 42 |
} |