8000 minor #41307 [Mailer] Remove dead code (jderusse) · symfony/symfony@5e19343 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e19343

Browse files
committed
minor #41307 [Mailer] Remove dead code (jderusse)
This PR was merged into the 5.2 branch. Discussion ---------- [Mailer] Remove dead code | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Since #40481 the `async-aws/ses` package is required, thus the class always exists. We can remove this check Commits ------- 52c1934 [mailer] Remove useless code
2 parents c9dea7c + 52c1934 commit 5e19343

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesTransportFactory.php

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
use AsyncAws\Core\Configuration;
1515
use AsyncAws\Ses\SesClient;
16-
use Symfony\Component\HttpClient\HttpClient;
17-
use Symfony\Component\Mailer\Exception\LogicException;
1816
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
1917
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
2018
use Symfony\Component\Mailer\Transport\Dsn;
@@ -35,46 +33,22 @@ public function create(Dsn $dsn): TransportInterface
3533
return new SesSmtpTransport($this->getUser($dsn), $this->getPassword($dsn), $region, $this->dispatcher, $this->logger);
3634
}
3735

38-
if (!class_exists(SesClient::class)) {
39-
if (!class_exists(HttpClient::class)) {
40-
throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component or AsyncAws package is not installed. Try running "composer require async-aws/ses".', __CLASS__));
41-
}
42-
43-
trigger_deprecation('symfony/amazon-mailer', '5.1', 'Using the "%s" transport without AsyncAws is deprecated. Try running "composer require async-aws/ses".', $scheme, static::class);
44-
45-
$user = $this->getUser($dsn);
46-
$password = $this->getPassword($dsn);
47-
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
48-
$port = $dsn->getPort();
49-
50-
if ('ses+api' === $scheme) {
51-
if (!\extension_loaded('simplexml')) {
52-
throw new LogicException(sprintf('Cannot use "%s". Make sure you have "ext-simplexml" installed and enabled.', SesApiTransport::class));
53-
}
54-
55-
return (new SesApiTransport($user, $password, $region, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
56-
}
57-
if ('ses+https' === $scheme || 'ses' === $scheme) {
58-
return (new SesHttpTransport($user, $password, $region, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
59-
}
60-
} else {
61-
switch ($scheme) {
62-
case 'ses+api':
63-
$class = SesApiAsyncAwsTransport::class;
64-
// no break
65-
case 'ses':
66-
case 'ses+https':
67-
$class = $class ?? SesHttpAsyncAwsTransport::class;
68-
$options = [
69-
'region' => $dsn->getOption('region') ?: 'eu-west-1',
70-
'accessKeyId' => $dsn->getUser(),
71-
'accessKeySecret' => $dsn->getPassword(),
72-
] + (
73-
'default' === $dsn->getHost() ? [] : ['endpoint' => 'https://'.$dsn->getHost().($dsn->getPort() ? ':'.$dsn->getPort() : '')]
74-
);
75-
76-
return new $class(new SesClient(Configuration::create($options), null, $this->client, $this->logger), $this->dispatcher, $this->logger);
77-
}
36+
switch ($scheme) {
37+
case 'ses+api':
38+
$class = SesApiAsyncAwsTransport::class;
39+
// no break
40+
case 'ses':
41+
case 'ses+https':
42+
$class = $class ?? SesHttpAsyncAwsTransport::class;
43+
$options = [
44+
'region' => $dsn->getOption('region') ?: 'eu-west-1',
45+
'accessKeyId' => $dsn->getUser(),
46+
'accessKeySecret' => $dsn->getPassword(),
47+
] + (
48+
'default' === $dsn->getHost() ? [] : ['endpoint' => 'https://'.$dsn->getHost().($dsn->getPort() ? ':'.$dsn->getPort() : '')]
49+
);
50+
51+
return new $class(new SesClient(Configuration::create($options), null, $this->client, $this->logger), $this->dispatcher, $this->logger);
7852
}
7953

8054
throw new UnsupportedSchemeException($dsn, 'ses', $this->getSupportedSchemes());

0 commit comments

Comments
 (0)
0