diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 1436fc0..7b82f2d 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\News\Controller; use Modules\Admin\Models\AccountMapper; -use Modules\Admin\Models\AccountPermissionMapper; use Modules\Admin\Models\NullAccount; use Modules\Media\Models\CollectionMapper; use Modules\Media\Models\MediaMapper; @@ -47,6 +46,16 @@ use phpOMS\Utils\Parser\Markdown\Markdown; */ 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 { $accounts = AccountMapper::findReadPermission( @@ -57,16 +66,16 @@ final class ApiController extends Controller ); foreach ($accounts as $account) { - $notification = new Notification(); - $notification->module = self::NAME; - $notification->title = $article->title; - $notification->createdAt = \DateTimeImmutable::createFromMutable($article->publish); - $notification->createdBy = $article->createdBy; + $notification = new Notification(); + $notification->module = self::NAME; + $notification->title = $article->title; + $notification->createdAt = \DateTimeImmutable::createFromMutable($article->publish); + $notification->createdBy = $article->createdBy; $notification->createdFor = new NullAccount($account); - $notification->type = NotificationType::CREATE; - $notification->category = PermissionCategory::NEWS; - $notification->element = $article->id; - $notification->redirect = '{/base}/news/article?{?}&id=' . $article->id; + $notification->type = NotificationType::CREATE; + $notification->category = PermissionCategory::NEWS; + $notification->element = $article->id; + $notification->redirect = '{/base}/news/article?{?}&id=' . $article->id; $this->createModel($request->header->account, $notification, NotificationMapper::class, 'notification', $request->getOrigin()); } diff --git a/Controller/SearchController.php b/Controller/SearchController.php index 9e1637d..5fe8dbd 100644 --- a/Controller/SearchController.php +++ b/Controller/SearchController.php @@ -76,10 +76,10 @@ final class SearchController extends Controller 'link' => '{/base}/news/article?id=' . $article->id, 'account' => '', 'createdAt' => $article->createdAt, - 'image' => '', - 'tags' => $article->tags, - 'type' => 'list_links', - 'module' => 'News', + 'image' => '', + 'tags' => $article->tags, + 'type' => 'list_links', + 'module' => 'News', ]; } @@ -124,10 +124,10 @@ final class SearchController extends Controller 'link' => '{/base}/news/article?id=' . $article->id, 'account' => '', 'createdAt' => $article->createdAt, - 'image' => '', - 'tags' => $article->tags, - 'type' => 'list_links', - 'module' => 'News', + 'image' => '', + 'tags' => $article->tags, + 'type' => 'list_links', + 'module' => 'News', ]; }