2022-03-18 03:28:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
|
|
|
|
|
|
|
|
use JsonSerializable;
|
2022-02-16 23:29:10 +00:00
|
|
|
use MediaWiki\Page\ProperPageIdentity;
|
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2022-03-18 03:28:06 +00:00
|
|
|
|
|
|
|
class DatabaseThreadItem implements JsonSerializable, ThreadItem {
|
|
|
|
use ThreadItemTrait;
|
|
|
|
|
2022-10-21 19:34:18 +00:00
|
|
|
private ProperPageIdentity $page;
|
|
|
|
private RevisionRecord $rev;
|
|
|
|
private string $type;
|
|
|
|
private string $name;
|
|
|
|
private string $id;
|
|
|
|
private ?DatabaseThreadItem $parent;
|
2022-03-18 03:28:06 +00:00
|
|
|
/** @var DatabaseThreadItem[] */
|
2022-10-21 19:34:18 +00:00
|
|
|
private array $replies = [];
|
2022-03-18 03:28:06 +00:00
|
|
|
/** @var string|bool */
|
|
|
|
private $transcludedFrom;
|
2022-10-21 19:34:18 +00:00
|
|
|
private int $level;
|
2022-03-18 03:28:06 +00:00
|
|
|
|
|
|
|
/**
|
2022-02-16 23:29:10 +00:00
|
|
|
* @param ProperPageIdentity $page
|
|
|
|
* @param RevisionRecord $rev
|
2022-03-18 03:28:06 +00:00
|
|
|
* @param string $type
|
|
|
|
* @param string $name
|
|
|
|
* @param string $id
|
|
|
|
* @param DatabaseThreadItem|null $parent
|
|
|
|
* @param bool|string $transcludedFrom
|
|
|
|
* @param int $level
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2022-02-16 23:29:10 +00:00
|
|
|
ProperPageIdentity $page, RevisionRecord $rev,
|
2022-03-18 03:28:06 +00:00
|
|
|
string $type, string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level
|
|
|
|
) {
|
2022-02-16 23:29:10 +00:00
|
|
|
$this->page = $page;
|
|
|
|
$this->rev = $rev;
|
2022-03-18 03:28:06 +00:00
|
|
|
$this->name = $name;
|
|
|
|
$this->id = $id;
|
|
|
|
$this->type = $type;
|
|
|
|
$this->parent = $parent;
|
|
|
|
$this->transcludedFrom = $transcludedFrom;
|
|
|
|
$this->level = $level;
|
|
|
|
}
|
|
|
|
|
2022-02-16 23:29:10 +00:00
|
|
|
public function getPage(): ProperPageIdentity {
|
|
|
|
return $this->page;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRevision(): RevisionRecord {
|
|
|
|
return $this->rev;
|
|
|
|
}
|
|
|
|
|
2022-03-18 03:28:06 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getName(): string {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param DatabaseThreadItem $reply Reply comment
|
|
|
|
*/
|
|
|
|
public function addReply( DatabaseThreadItem $reply ): void {
|
|
|
|
$this->replies[] = $reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getId(): string {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getType(): string {
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @return DatabaseThreadItem|null
|
|
|
|
*/
|
|
|
|
public function getParent(): ?ThreadItem {
|
|
|
|
return $this->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @return DatabaseThreadItem[]
|
|
|
|
*/
|
|
|
|
public function getReplies(): array {
|
|
|
|
return $this->replies;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getTranscludedFrom() {
|
|
|
|
return $this->transcludedFrom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getLevel(): int {
|
|
|
|
return $this->level;
|
|
|
|
}
|
|
|
|
}
|