1 | <?php namespace nyx\notify\transports\mail; |
||
12 | class Mailer implements interfaces\Mailer |
||
13 | { |
||
14 | /** |
||
15 | * @var interfaces\Driver The Driver used to actually send Messages. |
||
16 | */ |
||
17 | protected $driver; |
||
18 | |||
19 | /** |
||
20 | * @var \Illuminate\Contracts\View\Factory The View Factory responsible for creating the requested views. |
||
21 | */ |
||
22 | protected $viewFactory; |
||
23 | |||
24 | /** |
||
25 | * @var array An array of (optional) 'always to' and 'always from' addresses to simplify the creation and testing |
||
26 | * of Messages. |
||
27 | */ |
||
28 | protected $always = []; |
||
29 | |||
30 | /** |
||
31 | * @var int The maximum number of retries allowed to make upon driver connection failures. |
||
32 | */ |
||
33 | protected $allowedRetries = 5; |
||
34 | |||
35 | /** |
||
36 | * @var int The current number of connection retries made. |
||
37 | */ |
||
38 | protected $currentRetries = 0; |
||
39 | |||
40 | /** |
||
41 | * Constructs a new Mailer instance. |
||
42 | * |
||
43 | * @param interfaces\Driver $driver The Driver to use to actually send Messages. |
||
44 | * @param \Illuminate\Contracts\View\Factory $viewFactory The View Factory responsible for creating the requested views. |
||
45 | */ |
||
46 | public function __construct(interfaces\Driver $driver, \Illuminate\Contracts\View\Factory $viewFactory) |
||
51 | |||
52 | /** |
||
53 | * Sets the "always from" message header, which is used to populate the "from" field on Messages that do not yet |
||
54 | * have a sender set. |
||
55 | * |
||
56 | * @param string|array $address |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function setAlwaysFrom($address) : Mailer |
||
65 | |||
66 | /** |
||
67 | * Sets the "always to" message header, which is used to populate the "to" field on *all* outgoing Messages, |
||
68 | * regardless if they already have any recipients set. |
||
69 | * |
||
70 | * This functionality is primarily intended for testing purposes. |
||
71 | * |
||
72 | * @param string|array $address |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function setAlwaysTo($address) |
||
81 | |||
82 | /** |
||
83 | * {@inheritDoc} |
||
84 | */ |
||
85 | public function send($view, array $data = null, callable $builder = null, array &$failures = null) : int |
||
118 | |||
119 | /** |
||
120 | * Performs the actual sending of a MIME Message using the configured Driver. |
||
121 | * |
||
122 | * @param \Swift_Mime_Message $message The Message to send. |
||
123 | * @param array &$failures A reference to an array which will hold data about all requested |
||
124 | * recipients sending to whom failed. |
||
125 | * @return int The number of recipients the Message has been sent to. |
||
126 | */ |
||
127 | protected function doSend(\Swift_Mime_Message $message, array &$failures = null) : int |
||
154 | |||
155 | /** |
||
156 | * Attempts to recover from a Driver Exception by retrying delivery, restarting the Driver's Process if need be, |
||
157 | * unless the maximum number of allowed retries has been exceeded. |
||
158 | * |
||
159 | * @param \Swift_Mime_Message $message The Message we are trying to send. |
||
160 | * @param \Swift_TransportException $exception The Exception we are attempting to recover from. |
||
161 | * @param array &$failures A reference to an array which will hold data about all requested |
||
162 | * recipients sending to whom failed. |
||
163 | * @return int The number of recipients the Message has been sent to. |
||
164 | * @throws \RuntimeException When recovery was impossible due to exceeding the maximum number |
||
165 | * of allowed retries. |
||
166 | */ |
||
167 | protected function handleTransportException(\Swift_Mime_Message $message, \Swift_TransportException $exception, array &$failures = null) : int |
||
185 | |||
186 | /** |
||
187 | * Renders a Message's views and associates the resulting output as the body |
||
188 | * and respective MIME parts of the Message. |
||
189 | * |
||
190 | * @param Message $message The Message whose MIME entities should be set. |
||
191 | */ |
||
192 | protected function buildEntities(Message $message) |
||
214 | |||
215 | /** |
||
216 | * Determines what type of views (html, text or raw) are specified in the given $view value. |
||
217 | * |
||
218 | * @param string|array $view The value to base on. |
||
219 | * @return array A numerically indexed array with the respective view names corresponding to: |
||
220 | * 0 => html, 1 => text, 2 => raw view names. |
||
221 | * @throws \InvalidArgumentException If the given value is neither a string nor an array. |
||
222 | */ |
||
223 | protected function determineViews($view) : array |
||
244 | |||
245 | /** |
||
246 | * Creates a new Mail Message. |
||
247 | * |
||
248 | * @param string|array $view The view(s) to associate the Message with. |
||
249 | * @return Message |
||
250 | */ |
||
251 | protected function createMessage($view) : Message |
||
255 | } |
||
256 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.