Skip to content

Commit 161f567

Browse files
committed
Removed support for Laravel 7
1 parent 1279f8c commit 161f567

File tree

5 files changed

+13
-91
lines changed

5 files changed

+13
-91
lines changed

src/CreatesMailers.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,6 @@
88

99
trait CreatesMailers
1010
{
11-
protected function createLaravel6Mailer($app)
12-
{
13-
$config = $this->getConfig();
14-
15-
// Once we have create the mailer instance, we will set a container instance
16-
// on the mailer. This allows us to resolve mailer classes via containers
17-
// for maximum testability on said classes instead of passing Closures.
18-
$mailer = new Mailer(
19-
$app['view'],
20-
$app['swift.mailer'],
21-
$app['events']
22-
);
23-
24-
if ($app->bound('queue')) {
25-
$mailer->setQueue($app['queue']);
26-
}
27-
28-
// Next we will set all of the global addresses on this mailer, which allows
29-
// for easy unification of all "from" addresses as well as easy debugging
30-
// of sent messages since they get be sent into a single email address.
31-
foreach (['from', 'reply_to', 'to'] as $type) {
32-
$this->setGlobalAddress($mailer, $config, $type);
33-
}
34-
35-
return $mailer;
36-
}
37-
38-
protected function createLaravel7Mailer($app)
39-
{
40-
$defaultDriver = $app['mail.manager']->getDefaultDriver();
41-
$config = $this->getConfig($defaultDriver);
42-
43-
// Laravel 7 no longer bindes the swift.mailer:
44-
$swiftMailer = new Swift_Mailer($app['mail.manager']->createTransport($config));
45-
46-
// Once we have create the mailer instance, we will set a container instance
47-
// on the mailer. This allows us to resolve mailer classes via containers
48-
// for maximum testability on said classes instead of passing Closures.
49-
$mailer = new Laravel7Mailer(
50-
'smtp',
51-
$app['view'],
52-
$swiftMailer,
53-
$app['events']
54-
);
55-
56-
if ($app->bound('queue')) {
57-
$mailer->setQueue($app['queue']);
58-
}
59-
60-
// Next we will set all of the global addresses on this mailer, which allows
61-
// for easy unification of all "from" addresses as well as easy debugging
62-
// of sent messages since they get be sent into a single email address.
63-
foreach (['from', 'reply_to', 'to', 'return_path'] as $type) {
64-
$this->setGlobalAddress($mailer, $config, $type);
65-
}
66-
67-
return $mailer;
68-
}
6911

7012
protected function createLaravel8Mailer($app)
7113
{

src/HeloLaravelServiceProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ public function register()
4747
$this->app->singleton(Mailer::class, function ($app) {
4848
$version = $this->version($app);
4949

50-
if ($version < 7) {
51-
return $this->createLaravel6Mailer($app);
52-
}
53-
54-
if ($version < 8) {
55-
return $this->createLaravel7Mailer($app);
56-
}
57-
5850
if ($version < 9) {
5951
return $this->createLaravel8Mailer($app);
6052
}

src/Laravel7Mailer.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Laravel8Mailer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55
use Illuminate\Contracts\Mail\Factory as MailFactory;
66
use Illuminate\Contracts\Mail\Mailer as MailerContract;
77

8-
class Laravel8Mailer extends Laravel7Mailer implements MailerContract, MailFactory
8+
class Laravel8Mailer extends Mailer implements MailerContract, MailFactory
99
{
10+
public $currentMailer = null;
11+
protected $app;
12+
protected $mailers = [];
13+
14+
public function mailer($name = null)
15+
{
16+
$this->currentMailer = $name;
17+
18+
return $this;
19+
}
20+
1021
/**
1122
* Set laravel application.
1223
*

tests/HeloTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace BeyondCode\HeloLaravel\Tests;
44

5-
use BeyondCode\HeloLaravel\Laravel7Mailer;
65
use BeyondCode\HeloLaravel\Mailer;
76
use BeyondCode\HeloLaravel\TestMail;
87
use BeyondCode\HeloLaravel\TestMailCommand;
@@ -29,9 +28,5 @@
2928
test('the correct mailer is binded', function () {
3029
$mailer = app(Mailer::class);
3130

32-
if (version_compare(app()->version(), '7.0.0', '<')) {
33-
$this->assertTrue($mailer instanceof Mailer);
34-
} else {
35-
$this->assertTrue($mailer instanceof Laravel7Mailer);
36-
}
31+
$this->assertTrue($mailer instanceof Mailer);
3732
});

0 commit comments

Comments
 (0)