1 | <?php |
||
11 | class Mailer extends BaseMailer |
||
12 | { |
||
13 | /** |
||
14 | * The Swift Mailer Manager instance. |
||
15 | * |
||
16 | * @var \ElfSundae\Multimail\SwiftMailerManager |
||
17 | */ |
||
18 | protected $swiftManager; |
||
19 | |||
20 | /** |
||
21 | * The registered handler of sending message. |
||
22 | * |
||
23 | * @var \Closure|string |
||
24 | */ |
||
25 | protected $sendingMessageHandler; |
||
26 | |||
27 | /** |
||
28 | * Get the Swift Mailer Manager instance. |
||
29 | * |
||
30 | * @return \ElfSundae\Multimail\SwiftMailerManager |
||
31 | */ |
||
32 | 5 | public function getSwiftMailerManager() |
|
36 | |||
37 | /** |
||
38 | * Set the Swift Mailer Manager instance. |
||
39 | * |
||
40 | * @param \ElfSundae\Multimail\SwiftMailerManager $manager |
||
41 | * @return $this |
||
42 | */ |
||
43 | 7 | public function setSwiftMailerManager(SwiftMailerManager $manager) |
|
49 | |||
50 | /** |
||
51 | * Register handler of sending message. |
||
52 | * |
||
53 | * @param \Closure|string $handler |
||
54 | * @return $this |
||
55 | */ |
||
56 | 2 | public function registerSendingMessageHandler($handler) |
|
57 | { |
||
58 | 2 | $this->sendingMessageHandler = $handler; |
|
59 | |||
60 | 2 | return $this; |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * Call the registered handler of sending message. |
||
65 | * |
||
66 | * @param mixed ...$args |
||
67 | * @return mixed |
||
68 | */ |
||
69 | 3 | protected function callSendingMessageHandler(...$args) |
|
70 | { |
||
71 | 3 | if ($this->sendingMessageHandler instanceof Closure) { |
|
72 | 2 | return $this->container->call($this->sendingMessageHandler, $args); |
|
73 | } |
||
74 | |||
75 | 1 | if (is_string($this->sendingMessageHandler)) { |
|
76 | return $this->container->call($this->sendingMessageHandler, $args, 'sendingMessage'); |
||
77 | } |
||
78 | 1 | } |
|
79 | |||
80 | /** |
||
81 | * Get a Swift Mailer instance for the given message. |
||
82 | * |
||
83 | * @param mixed $message |
||
84 | * @return \Swift_Mailer |
||
85 | */ |
||
86 | 3 | protected function getSwiftMailerForMessage($message) |
|
96 | |||
97 | /** |
||
98 | * Send a new message using a view. |
||
99 | * |
||
100 | * @param string|array $view |
||
101 | * @param array $data |
||
102 | * @param \Closure|string $callback |
||
103 | */ |
||
104 | 3 | public function send($view, array $data = [], $callback = null) |
|
134 | |||
135 | /** |
||
136 | * Send a Swift Message instance. |
||
137 | * |
||
138 | * @param \Swift_Message $message |
||
139 | * @param \Swift_Mailer $swift |
||
140 | */ |
||
141 | 3 | protected function sendSwiftMessage($message, $swift = null) |
|
157 | |||
158 | /** |
||
159 | * Force the transport to re-connect. |
||
160 | * |
||
161 | * This will prevent errors in daemon queue situations. |
||
162 | * |
||
163 | * @param \Swift_Mailer $swift |
||
164 | */ |
||
165 | 3 | protected function forceReconnection($swift = null) |
|
173 | |||
174 | /** |
||
175 | * Get the Swift Mailer instance. |
||
176 | * |
||
177 | * @return \Swift_Mailer |
||
178 | */ |
||
179 | 1 | public function getSwiftMailer() |
|
183 | |||
184 | /** |
||
185 | * Set the Swift Mailer instance. |
||
186 | * |
||
187 | * @param string|\Swift_Mailer $swift |
||
188 | */ |
||
189 | 2 | public function setSwiftMailer($swift) |
|
196 | } |
||
197 |