@@ -40,8 +40,9 @@ public static function config(string $code, bool $failOnMissing = true): string|
40
40
return self ::$ config [$ code ]['value ' ];
41
41
}
42
42
43
- public static function mail (string $ to_name , string $ to_email , string $ subject , $ html , $ data = false )
43
+ public static function mail (string $ to_name , string $ to_email , string $ subject , $ html , $ data = false ): ? int
44
44
{
45
+ trigger_error ('Method ' .__METHOD__ .' is deprecated ' , E_USER_DEPRECATED );
45
46
$ sendgrid_api_key = self ::config ('sendgrid_api_key ' , true );
46
47
$ sendgrid_sender_email = self ::config ('sendgrid_sender_email ' , true );
47
48
$ sendgrid_sender_name = self ::config ('sendgrid_sender_name ' , true );
@@ -60,22 +61,16 @@ public static function mail(string $to_name, string $to_email, string $subject,
60
61
}
61
62
}
62
63
63
- // if ($data != false) {
64
- // // HTML is a Twig template with data
65
- // if(!site::$page->twig)
66
- // {
67
- // site::$page->getTwig();
68
- // }
69
- // $html = site::$page->twig->render($html, $data);
70
- // }
71
64
$ email ->addContent ('text/html ' , $ html );
72
65
$ sendgrid = new \SendGrid ($ sendgrid_api_key );
73
66
try {
74
67
$ response = $ sendgrid ->send ($ email );
75
68
76
69
return $ response ->statusCode ();
77
70
} catch (\Exception $ e ) {
78
- echo 'Caught exception: ' .$ e ->getMessage ()."\n" ;
71
+ Log::error ('Caught exception: ' .$ e ->getMessage ());
72
+
73
+ return null ;
79
74
}
80
75
}
81
76
@@ -117,4 +112,13 @@ public static function makeDirectory($root, $dir): bool
117
112
118
113
return true ;
119
114
}
115
+
116
+ public static function formatDate ($ date ): string
117
+ {
118
+ if (is_null ($ date )) {
119
+ return '- ' ;
120
+ }
121
+
122
+ return date ('d-m-Y H:i:s ' , strtotime ($ date ));
123
+ }
120
124
}
0 commit comments