#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,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet;
|
namespace adrienpayet\D2P\data;
|
||||||
|
|
||||||
class Author
|
class Author
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications;
|
namespace adrienpayet\D2P\data;
|
||||||
|
|
||||||
class Position
|
class Position
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications\location;
|
namespace adrienpayet\D2P\data\location;
|
||||||
|
|
||||||
class FileDetails
|
class FileDetails
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications\location;
|
namespace adrienpayet\D2P\data\location;
|
||||||
|
|
||||||
class Location
|
class Location
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications\location;
|
namespace adrienpayet\D2P\data\location;
|
||||||
use Kirby\Cms\Page;
|
use Kirby\Cms\Page;
|
||||||
|
|
||||||
class PageDetails
|
class PageDetails
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications\location;
|
namespace adrienpayet\D2P\data\location;
|
||||||
use Kirby;
|
use Kirby;
|
||||||
|
|
||||||
class ProjectDetails
|
class ProjectDetails
|
||||||
|
|
@ -15,96 +15,13 @@ class BaseComment {
|
||||||
protected $isRead;
|
protected $isRead;
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
$page = $data['page'];
|
$this->type = $data["type"];
|
||||||
$project = $page->template() == 'project' ? $page : $page->parent();
|
$this->location = new Location($data["location"]);
|
||||||
$file = $data['file'];
|
$this->text = $data["text"];
|
||||||
$position = $data['position'];
|
$this->author = new Author($data["author"]);
|
||||||
$replies = $data['replies'] ?? [];
|
$this->date = $data["date"];
|
||||||
$text = $data['text'];
|
$this->id = $data["id"];
|
||||||
$author = $data['author'];
|
$this->isRead = "false";
|
||||||
$date = $data['date'];
|
|
||||||
$id = $data['id'];
|
|
||||||
$type = $data['type'] ?? 'comment';
|
|
||||||
|
|
||||||
$this->location = [
|
|
||||||
'page' => [
|
|
||||||
'uri' => (string) $page->uri(),
|
|
||||||
'title' => (string) $page->title(),
|
|
||||||
],
|
|
||||||
'href' => (string) $data['href'],
|
|
||||||
'project' => [
|
|
||||||
'title' => (string) $project->title(),
|
|
||||||
'uri' => (string) $project->uri(),
|
|
||||||
],
|
|
||||||
'file' => $file ? [
|
|
||||||
'uuid' => (string) $file->uuid(),
|
|
||||||
'url' => (string) $file->uuid()
|
|
||||||
] : false,
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->replies = $replies ?? [];
|
|
||||||
$this->text = $text;
|
|
||||||
$this->author = [
|
|
||||||
'name' => (string) $author->name(),
|
|
||||||
'email' => (string) $author->email(),
|
|
||||||
'uuid' => (string) $author->uuid(),
|
|
||||||
'role' => (string) $author->role(),
|
|
||||||
];
|
|
||||||
$this->date = $date;
|
|
||||||
$this->id = $id;
|
|
||||||
$this->type = $type;
|
|
||||||
$this->isRead = false;
|
|
||||||
$this->position = $position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function location() {
|
|
||||||
return $this->location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function file() {
|
|
||||||
return $this->location['file'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function replies() {
|
|
||||||
return $this->replies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function text() {
|
|
||||||
return $this->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function author() {
|
|
||||||
return $this->author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function date() {
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function id() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function type() {
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isRead() {
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function read() {
|
|
||||||
$this->isRead = true;
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unread() {
|
|
||||||
$this->isRead = false;
|
|
||||||
return $this->isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pageIndex() {
|
|
||||||
$this->position['pageIndex'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ load([
|
||||||
|
|
||||||
F::loadClasses([
|
F::loadClasses([
|
||||||
'adrienpayet\\notifications\\Notification' => __DIR__ . '/src/Notification.php',
|
'adrienpayet\\notifications\\Notification' => __DIR__ . '/src/Notification.php',
|
||||||
'adrienpayet\\notifications\\location\\Location' => __DIR__ . '/src/location/Location.php',
|
'adrienpayet\\D2P\\data\\Position' => __DIR__ . '/../classes/Position.php',
|
||||||
'adrienpayet\\notifications\\location\\PageDetails' => __DIR__ . '/src/location/PageDetails.php',
|
'adrienpayet\\D2P\data\Author' => __DIR__ . '/../classes/Author.php',
|
||||||
'adrienpayet\\notifications\\location\\ProjectDetails' => __DIR__ . '/src/location/ProjectDetails.php',
|
'adrienpayet\\D2P\\data\\location\\Location' => __DIR__ . '/../classes/location/Location.php',
|
||||||
'adrienpayet\\notifications\\location\\FileDetails' => __DIR__ . '/src/location/FileDetails.php',
|
'adrienpayet\\D2P\\data\\location\\PageDetails' => __DIR__ . '/../classes/location/PageDetails.php',
|
||||||
'adrienpayet\\notifications\\Position' => __DIR__ . '/src/Position.php',
|
'adrienpayet\\D2P\\data\\location\\ProjectDetails' => __DIR__ . '/../classes/location/ProjectDetails.php',
|
||||||
'adrienpayet\\Author' => __DIR__ . '/../classes/Author.php'
|
'adrienpayet\\D2P\\data\\location\\FileDetails' => __DIR__ . '/../classes/location/FileDetails.php',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace adrienpayet\notifications;
|
namespace adrienpayet\notifications;
|
||||||
use adrienpayet\notifications\location\Location;
|
use adrienpayet\D2P\data\location\Location;
|
||||||
use adrienpayet\Author;
|
use adrienpayet\D2P\data\Author;
|
||||||
|
|
||||||
class Notification
|
class Notification
|
||||||
{
|
{
|
||||||
|
|
@ -23,7 +23,7 @@ class Notification
|
||||||
$this->author = new Author($data["author"]);
|
$this->author = new Author($data["author"]);
|
||||||
$this->date = $data["date"];
|
$this->date = $data["date"];
|
||||||
$this->id = $data["id"];
|
$this->id = $data["id"];
|
||||||
$this->isRead = $data["isRead"];
|
$this->isRead = "false";
|
||||||
|
|
||||||
if ($data["type"] === "comment") {
|
if ($data["type"] === "comment") {
|
||||||
$this->position = new Position($data["position"]);
|
$this->position = new Position($data["position"]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue