ReWork Notification Model/Module/Object/Repository/Factory

- Introduce Repository for interaction with "notify" table
- Introduce Factory for read-only notification objects (they're just loosely based on notification the table!)
- Introduce Objects for type-safe usage at the presentation layer
- Reworked Model, which is now fully based on the notify table, including generated fields (cache, ..)
This commit is contained in:
nupplaPhil 2020-01-25 02:01:49 +01:00
parent 230bb6dd53
commit 0850fb88dd
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
17 changed files with 1413 additions and 851 deletions

View file

@ -23,7 +23,11 @@ class Notification extends BaseModule
{
// @TODO: Replace with parameter from router
if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
$success = DI::notification()->setAllSeen();
try {
$success = DI::notification()->setAllSeen();
}catch (\Exception $e) {
$success = false;
}
header('Content-type: application/json; charset=utf-8');
echo json_encode([
@ -43,14 +47,16 @@ class Notification extends BaseModule
{
// @TODO: Replace with parameter from router
if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
$notificationManager = DI::notification();
// @TODO: Replace with parameter from router
$note = $notificationManager->getByID(DI::args()->get(2));
if (!empty($note)) {
$notificationManager->setSeen($note);
if (!empty($note['link'])) {
System::externalRedirect($note['link']);
try {
$notification = DI::notification()->getByID(DI::args()->get(2));
$notification->setSeen();
if (!empty($notification->link)) {
System::externalRedirect($notification->link);
}
} catch (HTTPException\NotFoundException $e) {
info(DI::l10n()->t('Invalid notification.'));
}
DI::baseUrl()->redirect();