-
Notifications
You must be signed in to change notification settings - Fork 475
Expand file tree
/
Copy pathDiscussion.php
More file actions
75 lines (64 loc) · 2.08 KB
/
Discussion.php
File metadata and controls
75 lines (64 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @file classes/mail/traits/Discussion.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Discussion
*
* @ingroup mail_traits
*
* @brief trait to support Discussion email template variables
*/
namespace PKP\mail\traits;
use Illuminate\Mail\Mailables\Headers;
use PKP\mail\variables\SubmissionEmailVariable;
trait Discussion
{
use Unsubscribe, CapturableReply {
Unsubscribe::getRequiredVariables as getTraitRequiredVariables;
Unsubscribe::headers as unsubscribeHeaders;
CapturableReply::headers as capturableReplyHeaders;
}
/**
* Merge the headers from the competing traits together.
*/
public function headers(): Headers
{
$unsubscribeHeaders = $this->unsubscribeHeaders();
$capturableReplyHeaders = $this->capturableReplyHeaders();
if ($unsubscribeHeaders->messageId !== null) {
throw new \Exception('Unable to merge message IDs!');
}
return new Headers(
$capturableReplyHeaders->messageId,
array_merge($unsubscribeHeaders->references, $capturableReplyHeaders->references),
array_merge($unsubscribeHeaders->text, $capturableReplyHeaders->text)
);
}
protected function addFooter(string $locale): self
{
$this->setupUnsubscribeFooter($locale, $this->context);
$this->setupCapturableReply();
return $this;
}
protected function setFooterText(string $locale, ?string $localeKey = null): string
{
if (is_null($localeKey)) {
$localeKey = 'emails.footer.unsubscribe.discussion';
}
return __($localeKey, [], $locale);
}
/**
* Adds email template variable class required to generate submission-related variables
*/
protected static function getRequiredVariables(): array
{
return array_merge(
static::getTraitRequiredVariables(),
[SubmissionEmailVariable::class]
);
}
}