function TransportServiceFactoryTrait::fromDsnObject

Constructs a transport instance given a DSN object.

Parameters

\Symfony\Component\Mailer\Transport\Dsn $dsn: The mailer DSN object.

Throws

\Symfony\Component\Mailer\Exception\IncompleteDsnException

\Symfony\Component\Mailer\Exception\UnsupportedSchemeException

1 call to TransportServiceFactoryTrait::fromDsnObject()
TransportServiceFactory::createTransport in core/lib/Drupal/Core/Mailer/TransportServiceFactory.php
Creates and returns a configured mailer transport class.

File

core/lib/Drupal/Core/Mailer/TransportServiceFactoryTrait.php, line 32

Class

TransportServiceFactoryTrait
A trait containing helper methods for transport service construction.

Namespace

Drupal\Core\Mailer

Code

protected function fromDsnObject(Dsn $dsn) : TransportInterface {
  foreach ($this->factories as $factory) {
    if ($factory->supports($dsn)) {
      return $factory->create($dsn);
    }
  }
  throw new UnsupportedSchemeException($dsn);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.