2020-10-27 12:57:12 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-10-27 12:57:12 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-10-27 12:57:12 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Mail\Engine;
|
|
|
|
|
|
|
|
class BaseEmailEngine implements EngineInterface
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
public $footer;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $variables;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $contact;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $subject;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $body;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $template_style;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-12-02 23:26:46 +01:00
|
|
|
public $attachments = [];
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2023-02-02 23:56:58 +01:00
|
|
|
public $attachment_links = [];
|
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $link;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public $text;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2021-02-22 01:18:52 +01:00
|
|
|
public $invitation;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-03-04 00:55:02 +01:00
|
|
|
public $text_body;
|
|
|
|
|
|
|
|
public $text_footer;
|
|
|
|
|
2023-02-02 23:56:58 +01:00
|
|
|
public int $max_attachment_size = 3000000;
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function setFooter($footer)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->footer = $footer;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setVariables($variables)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->variables = $variables;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setContact($contact)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->contact = $contact;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setSubject($subject)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
if (! empty($this->variables)) {
|
2020-11-05 11:14:30 +01:00
|
|
|
$subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject);
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|
2020-11-05 11:14:30 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->subject = $subject;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function setBody($body)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
if (! empty($this->variables)) {
|
2020-11-05 11:14:30 +01:00
|
|
|
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
|
2021-03-31 03:55:33 +02:00
|
|
|
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|
2020-11-05 11:14:30 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->body = $body;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function setTemplate($template_style)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->template_style = $template_style;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setAttachments($attachments)
|
|
|
|
{
|
2020-12-02 23:26:46 +01:00
|
|
|
$this->attachments = array_merge($this->getAttachments(), $attachments);
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2023-02-02 23:56:58 +01:00
|
|
|
public function setAttachmentLinks($links)
|
|
|
|
{
|
|
|
|
$this->attachment_links = array_merge($this->getAttachmentLinks(), $links);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function setViewLink($link)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->link = $link;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function setViewText($text)
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
$this->text = $text;
|
2020-10-27 12:57:12 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-03-04 00:55:02 +01:00
|
|
|
public function setTextBody($text)
|
|
|
|
{
|
2024-02-03 12:26:43 +01:00
|
|
|
|
|
|
|
if (! empty($this->variables)) {
|
2024-02-13 05:25:18 +01:00
|
|
|
|
2024-06-13 08:52:23 +02:00
|
|
|
$text = str_replace(['$paymentLink', '$viewButton', '$view_button', '$viewLink', '$view_link'], "\r\n\r\n".'$view_url'."\r\n", $text);
|
2024-02-03 12:26:43 +01:00
|
|
|
$text = str_replace(array_keys($this->variables), array_values($this->variables), $text);
|
|
|
|
$text = str_replace(array_keys($this->variables), array_values($this->variables), $text);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-04 00:55:02 +01:00
|
|
|
$this->text_body = $text;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function getSubject()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->subject;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function getBody()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->body;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getAttachments()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->attachments;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2023-02-02 23:56:58 +01:00
|
|
|
public function getAttachmentLinks()
|
|
|
|
{
|
|
|
|
return $this->attachment_links;
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function getFooter()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->footer;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function getTemplate()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->template_style;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewLink()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->link;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewText()
|
|
|
|
{
|
2020-11-25 15:19:52 +01:00
|
|
|
return $this->text;
|
2020-10-27 12:57:12 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
public function build()
|
|
|
|
{
|
|
|
|
}
|
2021-02-22 01:18:52 +01:00
|
|
|
|
|
|
|
public function setInvitation($invitation)
|
|
|
|
{
|
|
|
|
$this->invitation = $invitation;
|
2022-03-04 00:55:02 +01:00
|
|
|
|
|
|
|
return $this;
|
2021-02-22 01:18:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getInvitation()
|
|
|
|
{
|
|
|
|
return $this->invitation;
|
|
|
|
}
|
2022-03-04 00:55:02 +01:00
|
|
|
|
|
|
|
public function getTextBody()
|
|
|
|
{
|
|
|
|
return $this->text_body;
|
|
|
|
}
|
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|