Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer] Remove dead code #41307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

use AsyncAws\Core\Configuration;
use AsyncAws\Ses\SesClient;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\Mailer\Exception\LogicException;
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
Expand All @@ -35,46 +33,22 @@ public function create(Dsn $dsn): TransportInterface
return new SesSmtpTransport($this->getUser($dsn), $this->getPassword($dsn), $region, $this->dispatcher, $this->logger);
}

if (!class_exists(SesClient::class)) {
if (!class_exists(HttpClient::class)) {
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__));
}

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);

$user = $this->getUser($dsn);
$password = $this->getPassword($dsn);
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
$port = $dsn->getPort();

if ('ses+api' === $scheme) {
if (!\extension_loaded('simplexml')) {
throw new LogicException(sprintf('Cannot use "%s". Make sure you have "ext-simplexml" installed and enabled.', SesApiTransport::class));
}

return (new SesApiTransport($user, $password, $region, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
}
if ('ses+https' === $scheme || 'ses' === $scheme) {
return (new SesHttpTransport($user, $password, $region, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
}
} else {
switch ($scheme) {
case 'ses+api':
$class = SesApiAsyncAwsTransport::class;
// no break
case 'ses':
case 'ses+https':
$class = $class ?? SesHttpAsyncAwsTransport::class;
$options = [
'region' => $dsn->getOption('region') ?: 'eu-west-1',
'accessKeyId' => $dsn->getUser(),
'accessKeySecret' => $dsn->getPassword(),
] + (
'default' === $dsn->getHost() ? [] : ['endpoint' => 'https://'.$dsn->getHost().($dsn->getPort() ? ':'.$dsn->getPort() : '')]
);

return new $class(new SesClient(Configuration::create($options), null, $this->client, $this->logger), $this->dispatcher, $this->logger);
}
switch ($scheme) {
case 'ses+api':
$class = SesApiAsyncAwsTransport::class;
// no break
case 'ses':
case 'ses+https':
$class = $class ?? SesHttpAsyncAwsTransport::class;
$options = [
'region' => $dsn->getOption('region') ?: 'eu-west-1',
'accessKeyId' => $dsn->getUser(),
'accessKeySecret' => $dsn->getPassword(),
] + (
'default' === $dsn->getHost() ? [] : ['endpoint' => 'https://'.$dsn->getHost().($dsn->getPort() ? ':'.$dsn->getPort() : '')]
);

return new $class(new SesClient(Configuration::create($options), null, $this->client, $this->logger), $this->dispatcher, $this->logger);
}

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