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