mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-02-18 01:18:41 +00:00
code fixes
This commit is contained in:
parent
0f1632672c
commit
168f27cc66
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
||||||
namespace Modules\News\Controller;
|
namespace Modules\News\Controller;
|
||||||
|
|
||||||
use Modules\Admin\Models\AccountMapper;
|
use Modules\Admin\Models\AccountMapper;
|
||||||
use Modules\Admin\Models\AccountPermissionMapper;
|
|
||||||
use Modules\Admin\Models\NullAccount;
|
use Modules\Admin\Models\NullAccount;
|
||||||
use Modules\Media\Models\CollectionMapper;
|
use Modules\Media\Models\CollectionMapper;
|
||||||
use Modules\Media\Models\MediaMapper;
|
use Modules\Media\Models\MediaMapper;
|
||||||
|
|
@ -47,6 +46,16 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||||
*/
|
*/
|
||||||
final class ApiController extends Controller
|
final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Create notification for new articles
|
||||||
|
*
|
||||||
|
* @param NewsArticle $article News article
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function createNotifications(NewsArticle $article, RequestAbstract $request) : void
|
private function createNotifications(NewsArticle $article, RequestAbstract $request) : void
|
||||||
{
|
{
|
||||||
$accounts = AccountMapper::findReadPermission(
|
$accounts = AccountMapper::findReadPermission(
|
||||||
|
|
@ -57,16 +66,16 @@ final class ApiController extends Controller
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$notification = new Notification();
|
$notification = new Notification();
|
||||||
$notification->module = self::NAME;
|
$notification->module = self::NAME;
|
||||||
$notification->title = $article->title;
|
$notification->title = $article->title;
|
||||||
$notification->createdAt = \DateTimeImmutable::createFromMutable($article->publish);
|
$notification->createdAt = \DateTimeImmutable::createFromMutable($article->publish);
|
||||||
$notification->createdBy = $article->createdBy;
|
$notification->createdBy = $article->createdBy;
|
||||||
$notification->createdFor = new NullAccount($account);
|
$notification->createdFor = new NullAccount($account);
|
||||||
$notification->type = NotificationType::CREATE;
|
$notification->type = NotificationType::CREATE;
|
||||||
$notification->category = PermissionCategory::NEWS;
|
$notification->category = PermissionCategory::NEWS;
|
||||||
$notification->element = $article->id;
|
$notification->element = $article->id;
|
||||||
$notification->redirect = '{/base}/news/article?{?}&id=' . $article->id;
|
$notification->redirect = '{/base}/news/article?{?}&id=' . $article->id;
|
||||||
|
|
||||||
$this->createModel($request->header->account, $notification, NotificationMapper::class, 'notification', $request->getOrigin());
|
$this->createModel($request->header->account, $notification, NotificationMapper::class, 'notification', $request->getOrigin());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,10 @@ final class SearchController extends Controller
|
||||||
'link' => '{/base}/news/article?id=' . $article->id,
|
'link' => '{/base}/news/article?id=' . $article->id,
|
||||||
'account' => '',
|
'account' => '',
|
||||||
'createdAt' => $article->createdAt,
|
'createdAt' => $article->createdAt,
|
||||||
'image' => '',
|
'image' => '',
|
||||||
'tags' => $article->tags,
|
'tags' => $article->tags,
|
||||||
'type' => 'list_links',
|
'type' => 'list_links',
|
||||||
'module' => 'News',
|
'module' => 'News',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,10 +124,10 @@ final class SearchController extends Controller
|
||||||
'link' => '{/base}/news/article?id=' . $article->id,
|
'link' => '{/base}/news/article?id=' . $article->id,
|
||||||
'account' => '',
|
'account' => '',
|
||||||
'createdAt' => $article->createdAt,
|
'createdAt' => $article->createdAt,
|
||||||
'image' => '',
|
'image' => '',
|
||||||
'tags' => $article->tags,
|
'tags' => $article->tags,
|
||||||
'type' => 'list_links',
|
'type' => 'list_links',
|
||||||
'module' => 'News',
|
'module' => 'News',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user