1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Notifications\Messages\Builder; |
4
|
|
|
|
5
|
|
|
use ByTIC\Common\Records\Emails\EmailTrait; |
|
|
|
|
6
|
|
|
use ByTIC\Common\Records\Emails\Builder\ViewBuilder as GenericBuilder; |
|
|
|
|
7
|
|
|
use ByTIC\Notifications\Notifications\AbstractNotification as Notification; |
8
|
|
|
use ByTIC\Notifications\Notifiable; |
9
|
|
|
use Nip\Records\AbstractModels\Record; |
10
|
|
|
use Nip\Records\Locator\ModelLocator; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class AbstractBuilder |
14
|
|
|
* |
15
|
|
|
* @package ByTIC\Notifications\Messages\Builder |
16
|
|
|
*/ |
17
|
|
|
abstract class EmailBuilder extends GenericBuilder |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Model of notifiable trait |
22
|
|
|
* |
23
|
|
|
* @var Record|Notifiable |
24
|
|
|
*/ |
25
|
|
|
protected $notifiable = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var array|null |
29
|
|
|
*/ |
30
|
|
|
protected $mergeFields = null; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @inheritdoc |
34
|
|
|
*/ |
35
|
|
|
public function compile() |
36
|
|
|
{ |
37
|
|
|
parent::compile(); |
38
|
|
|
$this->compileMergeFields(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function compileMergeFields() |
42
|
|
|
{ |
43
|
|
|
$mergeFields = $this->getMergeFields(); |
44
|
|
|
foreach ($mergeFields as $group => $fields) { |
45
|
|
|
foreach ($fields as $field) { |
46
|
|
|
$this->setMergeTag($field, $this->getMergeFieldValue($field)); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return array |
53
|
|
|
*/ |
54
|
|
|
public function getMergeFields() |
55
|
|
|
{ |
56
|
|
|
if ($this->mergeFields === null) { |
57
|
|
|
$this->mergeFields = $this->generateMergeFields(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $this->mergeFields; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Generates the MergeFields array |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
public function generateMergeFields() |
69
|
|
|
{ |
70
|
|
|
return []; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** @noinspection PhpUnusedParameterInspection |
74
|
|
|
* |
75
|
|
|
* Get the MergeField value |
76
|
|
|
* |
77
|
|
|
* @param string $field Field Name |
78
|
|
|
* |
79
|
|
|
* @return null |
80
|
|
|
*/ |
81
|
|
|
public function getMergeFieldValue($field) |
82
|
|
|
{ |
83
|
|
|
return null; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param EmailTrait $email |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
|
|
protected function hydrateEmail($email) |
91
|
|
|
{ |
92
|
|
|
$notifiable = $this->getNotifiable(); |
93
|
|
|
if (method_exists($notifiable, 'routeNotificationFor')) { |
94
|
|
|
$email->to = $this->getNotifiable()->routeNotificationFor('mail'); |
95
|
|
|
} |
96
|
|
|
return parent::hydrateEmail($email); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Set the Notifiable instance |
101
|
|
|
* |
102
|
|
|
* @return Record|Notifiable |
103
|
|
|
*/ |
104
|
|
|
public function getNotifiable() |
105
|
|
|
{ |
106
|
|
|
return $this->notifiable; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Set the Notifiable instance |
111
|
|
|
* |
112
|
|
|
* @param Record $notifiable Notifiable record |
113
|
|
|
* |
114
|
|
|
* @return void |
115
|
|
|
*/ |
116
|
|
|
public function setNotifiable($notifiable) |
117
|
|
|
{ |
118
|
|
|
$this->notifiable = $notifiable; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @inheritdoc |
123
|
|
|
*/ |
124
|
|
|
protected function getEmailsManager() |
125
|
|
|
{ |
126
|
|
|
return ModelLocator::get('emails'); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths