mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-17 00:55:07 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\News;
|
|
|
|
use App\Modules\Platform\Settings\Setting;
|
|
use App\Modules\Platform\Settings\Settings;
|
|
|
|
/**
|
|
* Reads back what FetchNewsCommand cached — no capability check (both
|
|
* editions get news) and no permission check (that happens one layer up,
|
|
* in whatever controller decides whether to call current() at all — see
|
|
* DashboardController), matching LatestReleaseInfo's own division of
|
|
* responsibility.
|
|
*/
|
|
class NewsItems
|
|
{
|
|
public function __construct(
|
|
private readonly Settings $settings,
|
|
) {}
|
|
|
|
/**
|
|
* @return list<array{title: string, date: string, content: string, link: string}>
|
|
*/
|
|
public function current(): array
|
|
{
|
|
$items = $this->settings->get(Setting::NewsItems);
|
|
|
|
if (! is_array($items)) {
|
|
return [];
|
|
}
|
|
|
|
return array_values(array_filter(
|
|
$items,
|
|
fn (mixed $item): bool => is_array($item)
|
|
&& is_string($item['title'] ?? null)
|
|
&& is_string($item['date'] ?? null)
|
|
&& is_string($item['content'] ?? null)
|
|
&& is_string($item['link'] ?? null),
|
|
));
|
|
}
|
|
}
|