/
DriverInterface.php
60 lines (53 loc) · 1.92 KB
/
DriverInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Mail;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Support\MessageBag;
use Swift_Transport;
/**
* An interface for a mail service.
*
* This interface provides all methods necessary for configuring, checking and
* using one of Laravel's various email drivers throughout Flarum.
*
* @public
*/
interface DriverInterface
{
/**
* Provide a list of settings for this driver.
*
* The list must be an array of field names (keys) mapping to their type
* (the empty string "" for a text field; or an array of possible values for
* a dropdown field).
*/
public function availableSettings(): array;
/**
* Ensure the given settings are enough to send emails.
*
* This method is responsible for determining whether the user-provided
* values stored in Flarum's settings are "valid" as far as a simple
* inspection of these values can determine it. Of course, this does not
* mean that the mail server or API will actually accept e.g. credentials.
*
* Any errors must be wrapped in a {@see \Illuminate\Support\MessageBag}.
* If there are no errors, an empty instance can be returned. In the
* presence of validation problems with the configured mail driver, Flarum
* will fall back to its no-op {@see \Flarum\Mail\NullDriver}.
*/
public function validate(SettingsRepositoryInterface $settings, Factory $validator): MessageBag;
/**
* Does this driver actually send out emails?
*/
public function canSend(): bool;
/**
* Build a mail transport based on Flarum's current settings.
*/
public function buildTransport(SettingsRepositoryInterface $settings): Swift_Transport;
}