| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\DiscussionTools\ThreadItem; |
| 4 |
|
| 5 |
use JsonSerializable; |
| 6 |
use MediaWiki\Page\ProperPageIdentity; |
| 7 |
use MediaWiki\Revision\RevisionRecord; |
| 8 |
|
| 9 |
class DatabaseThreadItem implements JsonSerializable, ThreadItem { |
| 10 |
use ThreadItemTrait; |
| 11 |
|
| 12 |
private ProperPageIdentity $page; |
| 13 |
private RevisionRecord $rev; |
| 14 |
private string $type; |
| 15 |
private string $name; |
| 16 |
private string $id; |
| 17 |
private ?DatabaseThreadItem $parent; |
| 18 |
|
| 19 |
private array $replies = []; |
| 20 |
|
| 21 |
private $transcludedFrom; |
| 22 |
private int $level; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public function __construct( |
| 35 |
ProperPageIdentity $page, RevisionRecord $rev, |
| 36 |
string $type, string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level |
| 37 |
) { |
| 38 |
$this->page = $page; |
| 39 |
$this->rev = $rev; |
| 40 |
$this->name = $name; |
| 41 |
$this->id = $id; |
| 42 |
$this->type = $type; |
| 43 |
$this->parent = $parent; |
| 44 |
$this->transcludedFrom = $transcludedFrom; |
| 45 |
$this->level = $level; |
| 46 |
} |
| 47 |
|
| 48 |
public function getPage(): ProperPageIdentity { |
| 49 |
return $this->page; |
| 50 |
} |
| 51 |
|
| 52 |
public function getRevision(): RevisionRecord { |
| 53 |
return $this->rev; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public function getName(): string { |
| 60 |
return $this->name; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public function addReply( DatabaseThreadItem $reply ): void { |
| 67 |
$this->replies[] = $reply; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public function getId(): string { |
| 74 |
return $this->id; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public function getType(): string { |
| 81 |
return $this->type; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public function getParent(): ?ThreadItem { |
| 89 |
return $this->parent; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
public function getReplies(): array { |
| 97 |
return $this->replies; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
public function getTranscludedFrom() { |
| 104 |
return $this->transcludedFrom; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
public function getLevel(): int { |
| 111 |
return $this->level; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
public function isCanonicalPermalink(): bool { |
| 119 |
return $this->getRevision()->isCurrent() && !is_string( $this->getTranscludedFrom() ); |
| 120 |
} |
| 121 |
} |