You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/app/Services/UserDrawerService.php

34 lines
1.1 KiB
PHP

<?php
namespace App\Services;
use App\Services\Cloud\CloudAccess;
/**
* Safe, non-sensitive bootstrap data shared by the user shell drawers.
*
* Account settings, payment configuration and referral data remain inside
* their authenticated drawer documents. Only published announcement fields
* are embedded in the parent page so the first open can render immediately.
*/
final class UserDrawerService
{
public static function announcementBootstrapJson(): string
{
try {
$payload = AnnouncementService::published(
CloudAccess::actor(false),
['page' => 1, 'per_page' => 10]
);
$json = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG
| JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
| JSON_INVALID_UTF8_SUBSTITUTE);
return $json === false ? '{}' : $json;
} catch (\Throwable $error) {
// The drawer can still revalidate through its existing API path if
// the optional first-page bootstrap is unavailable.
return '{}';
}
}
}