#68 - refactor some of the notification classes to classes plugin to share them with comments
This commit is contained in:
parent
6ab18b1066
commit
3d4ddc12fc
9 changed files with 22 additions and 105 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications;
|
||||
use adrienpayet\notifications\location\Location;
|
||||
use adrienpayet\Author;
|
||||
use adrienpayet\D2P\data\location\Location;
|
||||
use adrienpayet\D2P\data\Author;
|
||||
|
||||
class Notification
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ class Notification
|
|||
$this->author = new Author($data["author"]);
|
||||
$this->date = $data["date"];
|
||||
$this->id = $data["id"];
|
||||
$this->isRead = $data["isRead"];
|
||||
$this->isRead = "false";
|
||||
|
||||
if ($data["type"] === "comment") {
|
||||
$this->position = new Position($data["position"]);
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications;
|
||||
|
||||
class Position
|
||||
{
|
||||
public int $pageIndex;
|
||||
public float $x;
|
||||
public float $y;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->pageIndex = $data['pageIndex'];
|
||||
$this->x = (float) $data['x'];
|
||||
$this->y = (float) $data['y'];
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [
|
||||
"pageIndex" => $this->pageIndex,
|
||||
"x" => $this->x,
|
||||
"y" => $this->y,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications\location;
|
||||
|
||||
class FileDetails
|
||||
{
|
||||
public string $uuid;
|
||||
public string $url;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = (string) $data->uuid();
|
||||
$this->url = (string) $data->url();
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [
|
||||
"uuid" => $this->uuid,
|
||||
"url" => $this->url
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications\location;
|
||||
|
||||
class Location
|
||||
{
|
||||
protected PageDetails $page;
|
||||
protected ?string $dialogUri = null;
|
||||
protected ProjectDetails $project;
|
||||
protected ?FileDetails $file = null;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->page = new PageDetails($data["page"]);
|
||||
$this->dialogUri = $data["dialogUri"];
|
||||
$this->project = new ProjectDetails($data["project"]);
|
||||
|
||||
if (isset($data['file'])) {
|
||||
$this->file = new FileDetails($data["file"]);
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
$array = [
|
||||
"page" => $this->page->toArray(),
|
||||
"project" => $this->project->toArray(),
|
||||
];
|
||||
|
||||
if ($this->dialogUri) {
|
||||
$array["dialogUri"] = $this->dialogUri;
|
||||
$array["file"] = $this->file;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications\location;
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
class PageDetails
|
||||
{
|
||||
protected Page $page;
|
||||
|
||||
public function __construct(Page $page)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [
|
||||
"uri" => (string) $this->page->uri(),
|
||||
"title" => (string) $this->page->title(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\notifications\location;
|
||||
use Kirby;
|
||||
|
||||
class ProjectDetails
|
||||
{
|
||||
public string $title;
|
||||
public string $uri;
|
||||
|
||||
public function __construct(Kirby\Cms\Page $page)
|
||||
{
|
||||
$this->title = (string) $page->title();
|
||||
$this->uri = (string) $page->uri();
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [
|
||||
"title" => $this->title,
|
||||
"uri" => $this->uri
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue