1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 01:11:34 +02:00
invoiceninja/app/Mail/Engine/BaseEmailEngine.php

211 lines
3.7 KiB
PHP
Raw Normal View History

2020-10-27 12:57:12 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. 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
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-03-04 00:55:02 +01:00
public $text_body;
public $text_footer;
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
}
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);
$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
}
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
}
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
}
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-03-04 00:55:02 +01:00
public function setTextBody($text)
{
$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
}
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
}
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
}
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
}
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;
}
private function replaceEntities($content)
{
$find = [
'<p>',
'</p>',
'<div class="center">',
'<\div>',
];
$replace = [
'',
'\n\n',
'',
'\n\n',
];
return str_replace($find, $replace, $content);
}
2020-11-25 15:19:52 +01:00
}