#68 - reply working + remove marker on comment delete
This commit is contained in:
parent
cf83edc1e6
commit
231bb21a4f
9 changed files with 64 additions and 95 deletions
|
|
@ -3,14 +3,16 @@
|
|||
namespace adrienpayet\comments;
|
||||
use adrienpayet\D2P\data\location\Location;
|
||||
use adrienpayet\D2P\data\Author;
|
||||
use adrienpayet\D2P\data\Position;
|
||||
|
||||
class BaseComment {
|
||||
protected string $type;
|
||||
protected Location $location;
|
||||
protected string $text;
|
||||
protected Author $author;
|
||||
protected string $text;
|
||||
protected string $date;
|
||||
protected string $id;
|
||||
protected Position $position;
|
||||
|
||||
public function __construct($data) {
|
||||
$this->location = new Location($data["location"]);
|
||||
|
|
@ -18,11 +20,13 @@ class BaseComment {
|
|||
$this->author = new Author($data["author"]);
|
||||
$this->date = $data["date"];
|
||||
$this->id = $data["id"];
|
||||
$this->position = new Position($data['position']);
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [
|
||||
"location" => $this->location->toArray(),
|
||||
"position" => $this->position->toArray(),
|
||||
"text" => $this->text,
|
||||
"author" => $this->author->toArray(),
|
||||
"date" => $this->date,
|
||||
|
|
|
|||
|
|
@ -1,24 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\comments;
|
||||
use adrienpayet\D2P\data\Position;
|
||||
|
||||
class Comment extends BaseComment
|
||||
{
|
||||
protected ?Position $position = null;
|
||||
protected string $type = "comment";
|
||||
protected array $replies = [];
|
||||
|
||||
public function __construct($data) {
|
||||
parent::__construct($data);
|
||||
if (isset($data["position"])) {
|
||||
$this->position = new Position($data['position']);
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
$array = parent::toArray();
|
||||
$array['position'] = $this->position;
|
||||
$array['type'] = $this->type;
|
||||
$array['replies'] = $this->replies;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,21 +3,20 @@ namespace adrienpayet\comments;
|
|||
|
||||
class Reply extends BaseComment {
|
||||
|
||||
protected $parentId;
|
||||
protected string $type = "comment-reply";
|
||||
|
||||
public function __construct($data) {
|
||||
parent::__construct($data);
|
||||
$this->parentId = $data['parentId'];
|
||||
$this->location->setParentCommentId($data["parentId"]);
|
||||
}
|
||||
|
||||
|
||||
public function parentId() {
|
||||
return $this->parentId;
|
||||
return $this->location->parentId();
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
$array = parent::toArray();
|
||||
$array['parentId'] = $this->parentId;
|
||||
$array['type'] = $this->type;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue