feat(admin): improve payments and server settings
This commit is contained in:
@@ -49,6 +49,19 @@ final class MailSettings
|
||||
return self::resolve()['transport'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{cc: array<int, string>, bcc: array<int, string>}
|
||||
*/
|
||||
public static function recipients(): array
|
||||
{
|
||||
$settings = self::resolve();
|
||||
|
||||
return [
|
||||
'cc' => $settings['cc'] ?? [],
|
||||
'bcc' => $settings['bcc'] ?? [],
|
||||
];
|
||||
}
|
||||
|
||||
public static function refresh(object $mailer): void
|
||||
{
|
||||
self::apply();
|
||||
@@ -91,6 +104,8 @@ final class MailSettings
|
||||
'transport' => $transport,
|
||||
'from_address' => ($mail->from_address ?? null) ?: ($mail->user ?? null),
|
||||
'from_name' => ($mail->from_name ?? null) ?: $company,
|
||||
'cc' => self::emailList($mail->cc ?? []),
|
||||
'bcc' => self::emailList($mail->bcc ?? []),
|
||||
'mailer' => array_filter([
|
||||
'transport' => $transport,
|
||||
'host' => $mail->host ?? '',
|
||||
@@ -102,4 +117,17 @@ final class MailSettings
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private static function emailList(mixed $value): array
|
||||
{
|
||||
$emails = is_array($value) ? $value : preg_split('/[,;\s]+/', (string) $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
return array_values(array_unique(array_filter(
|
||||
array_map(fn ($email) => strtolower(trim((string) $email)), $emails ?: []),
|
||||
fn (string $email) => filter_var($email, FILTER_VALIDATE_EMAIL) !== false,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user