/var/www/html_fr/wp-content/plugins/fluent-smtp/app/Services/Mailer/Providers/Factory.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
<?php

namespace FluentMail\App\Services\Mailer\Providers;

use 
InvalidArgumentException;
use 
FluentMail\App\Models\Settings;
use 
FluentMail\Includes\Core\Application;

class 
Factory
{
    protected 
$app null;

    protected 
$settings null;

    public function 
__construct(Application $appSettings $settings)
    {
        
$this->app $app;
        
        
$this->settings $settings;
    }

    public function 
make($provider)
    {
        return 
$this->app->make($provider);
    }

    public function 
get($email)
    {
        if (!(
$conn $this->settings->getConnection($email))) {
            
$conn $this->getDefaultProvider();
        }
        
        if (
$conn) {
            
$settings array_merge($conn['provider_settings'], [
                
'title' => $conn['title']
            ]);
            
            return 
$this->make(
                
$conn['provider_settings']['provider']
            )->
setSettings($settings);
        }
        

        throw new 
InvalidArgumentException(
            
esc_html__('There is no matching provider found by email: ''fluent-smtp') . $email // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
        
);
    }

    public function 
getDefaultProvider()
    {
        return 
fluentMailDefaultConnection();
    }
}