1 | <?php |
||
32 | class MailService extends AbstractPluginManager |
||
33 | { |
||
34 | /** |
||
35 | * Define transport type to use |
||
36 | */ |
||
37 | const TRANSPORT_SMTP = 'smtp'; |
||
38 | const TRANSPORT_FILE = 'file'; |
||
39 | const TRANSPORT_SENDMAIL = 'sendmail'; |
||
40 | |||
41 | /** |
||
42 | * The mail Transport |
||
43 | * |
||
44 | * @var TransportInterface |
||
45 | */ |
||
46 | protected $transport; |
||
47 | |||
48 | /** |
||
49 | * Default from address to use if no from address is set in the mail. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $from; |
||
54 | |||
55 | /** |
||
56 | * Value for the X-Mailer header. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $mailer; |
||
61 | |||
62 | /** |
||
63 | * If set, all mails are send to the addresses in this list |
||
64 | * |
||
65 | * This is useful when developing. |
||
66 | * |
||
67 | * @var AddressList|null |
||
68 | */ |
||
69 | protected $overrideRecipient; |
||
70 | |||
71 | protected $language; |
||
72 | |||
73 | protected $shareByDefault = false; |
||
74 | |||
75 | protected $invokableClasses = array( |
||
76 | 'simple' => '\Zend\Mail\Message', |
||
77 | 'stringtemplate' => '\Core\Mail\StringTemplateMessage', |
||
78 | ); |
||
79 | |||
80 | protected $factories = array( |
||
81 | 'htmltemplate' => [HTMLTemplateMessage::class,'factory'], |
||
82 | ); |
||
83 | |||
84 | /** |
||
85 | * Creates an instance. |
||
86 | * |
||
87 | * Adds two default initializers: |
||
88 | * - Inject the translator to mails implementing TranslatorAwareInterface |
||
89 | * - Call init() method on Mails if such method exists. |
||
90 | * |
||
91 | * @param ContainerInterface $container |
||
92 | * @param mixed $configuration |
||
93 | */ |
||
94 | public function __construct($container, $configuration = []) |
||
131 | |||
132 | /** |
||
133 | * Checks that a plugin is a child of an email message. |
||
134 | * |
||
135 | * @throws \InvalidArgumentException |
||
136 | */ |
||
137 | public function validate($plugin) |
||
148 | |||
149 | /** |
||
150 | * Gets the default from address |
||
151 | * |
||
152 | * @return null|String|Address|AddressList|array |
||
153 | */ |
||
154 | public function getFrom() |
||
158 | |||
159 | /** |
||
160 | * Sets the default from address. |
||
161 | * |
||
162 | * @param string|AddressList|Address $email |
||
163 | * @param String|null $name |
||
164 | * |
||
165 | * @return self |
||
166 | */ |
||
167 | public function setFrom($email, $name = null) |
||
179 | |||
180 | /** |
||
181 | * Sets override recipients. |
||
182 | * |
||
183 | * @param AddressList $recipients |
||
184 | * |
||
185 | * @return self |
||
186 | */ |
||
187 | public function setOverrideRecipient(AddressList $recipients) |
||
193 | |||
194 | /** |
||
195 | * Sends a mail. |
||
196 | * |
||
197 | * Sets default values where needed. |
||
198 | * |
||
199 | * @param string|MailMessage $mail |
||
200 | * @param array $options |
||
201 | */ |
||
202 | public function send($mail, array $options = array()) |
||
245 | |||
246 | /** |
||
247 | * Gets the transport. |
||
248 | * |
||
249 | * @return TransportInterface $transport |
||
250 | */ |
||
251 | public function getTransport() |
||
255 | |||
256 | /** |
||
257 | * Sets the transport |
||
258 | * |
||
259 | * @param TransportInterface $transport |
||
260 | * |
||
261 | * @return self |
||
262 | */ |
||
263 | public function setTransport(TransportInterface $transport) |
||
269 | |||
270 | /** |
||
271 | * Gest the value of the X-Mailer header. |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | public function getMailer() |
||
279 | |||
280 | /** |
||
281 | * Sets the value for the X-Mailer header |
||
282 | * |
||
283 | * @param string $mailer |
||
284 | * |
||
285 | * @return $this |
||
286 | */ |
||
287 | public function setMailer($mailer) |
||
293 | } |
||
294 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.