PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.25
Booking for Appointments and Events Calendar – Amelia v1.2.25
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / Services / Notification / OutlookService.php
ameliabooking / src / Infrastructure / Services / Notification Last commit date
MailerFactory.php 1 year ago MailgunService.php 1 year ago OutlookService.php 1 year ago PHPMailService.php 1 year ago SMTPService.php 1 year ago WpMailService.php 1 year ago
OutlookService.php
84 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Infrastructure\Services\Notification;
8
9 use AmeliaBooking\Domain\Services\Notification\AbstractMailService;
10 use AmeliaBooking\Domain\Services\Notification\MailServiceInterface;
11 use AmeliaBooking\Infrastructure\Services\Outlook\AbstractOutlookCalendarService;
12 use Exception;
13
14 /**
15 * Class OutlookService
16 */
17 class OutlookService extends AbstractMailService implements MailServiceInterface
18 {
19 /** @var AbstractOutlookCalendarService */
20 private $outlookCalendarService;
21
22 /**
23 * OutlookService constructor.
24 *
25 * @param AbstractOutlookCalendarService $outlookCalendarService
26 * @param string $from
27 * @param string $fromName
28 * @param string $replyTo
29 */
30 public function __construct($outlookCalendarService, $from, $fromName, $replyTo)
31 {
32 $this->outlookCalendarService = $outlookCalendarService;
33
34 parent::__construct($from, $fromName, $replyTo);
35 }
36
37 /** @noinspection MoreThanThreeArgumentsInspection */
38 /**
39 * @param string $to
40 * @param string $subject
41 * @param string $body
42 * @param array $bcc
43 * @param array $attachments
44 *
45 * @return void
46 * @throws Exception
47 * @SuppressWarnings(PHPMD)
48 */
49 public function send($to, $subject, $body, $bcc = [], $attachments = [])
50 {
51 $attachmentsList = [];
52
53 foreach ($attachments as $attachment) {
54 if (!empty($attachment['content'])) {
55 $isInvoice = strpos($attachment['type'], 'pdf') !== false;
56
57 if ($isInvoice) {
58 $tmpFile = tempnam(sys_get_temp_dir(), 'Invoice_');
59 } else {
60 $tmpFile = tempnam(sys_get_temp_dir(), 'cal_');
61 }
62
63 if ($tmpFile &&
64 file_put_contents($tmpFile, $attachment['content']) !== false &&
65 @rename($tmpFile, $tmpFile .= ($isInvoice ? '.pdf' : '.ics')) !== false
66 ) {
67 $attachmentsList[] = ['filePath' => $tmpFile, 'fileName' => $attachment['name']];
68 }
69 }
70 }
71
72 $this->outlookCalendarService->sendEmail(
73 $this->from,
74 $this->fromName,
75 $this->replyTo,
76 $to,
77 $subject,
78 $body,
79 $bcc,
80 $attachmentsList
81 );
82 }
83 }
84