Fix Pint formatting
This commit is contained in:
@@ -5,7 +5,9 @@ namespace App\Services\Communication;
|
||||
class CommunicationPreviewService
|
||||
{
|
||||
private CommunicationTemplateService $templates;
|
||||
|
||||
private CommunicationStudentService $students;
|
||||
|
||||
private CommunicationFamilyService $families;
|
||||
|
||||
public function __construct(
|
||||
@@ -26,7 +28,7 @@ class CommunicationPreviewService
|
||||
string $teacherName
|
||||
): array {
|
||||
$template = $this->templates->findTemplateByKey($templateKey);
|
||||
if (!$template) {
|
||||
if (! $template) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
@@ -35,7 +37,7 @@ class CommunicationPreviewService
|
||||
}
|
||||
|
||||
$student = $this->students->getStudentBasic($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
@@ -46,7 +48,7 @@ class CommunicationPreviewService
|
||||
$salutation = $this->families->guardianSalutation($familyId);
|
||||
|
||||
$autoVars = [
|
||||
'student_fullname' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
|
||||
'student_fullname' => trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? '')),
|
||||
'student_grade' => $student['grade'] ?? '',
|
||||
'parent_salutation' => $salutation,
|
||||
'date' => $this->formatLocalDate('Y-m-d'),
|
||||
@@ -70,6 +72,7 @@ class CommunicationPreviewService
|
||||
{
|
||||
return (string) preg_replace_callback('/\\{\\{\\s*([a-zA-Z0-9_\\.]+)\\s*\\}\\}/', function ($m) use ($vars) {
|
||||
$key = $m[1];
|
||||
|
||||
return htmlspecialchars((string) ($vars[$key] ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
}, $template);
|
||||
}
|
||||
@@ -79,6 +82,7 @@ class CommunicationPreviewService
|
||||
if (function_exists('local_date') && function_exists('utc_now')) {
|
||||
return (string) local_date(utc_now(), $format);
|
||||
}
|
||||
|
||||
return now()->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user