class TransportServiceFactory

The default mailer transport service factory.

Hierarchy

Expanded class hierarchy of TransportServiceFactory

File

core/lib/Drupal/Core/Mailer/TransportServiceFactory.php, line 15

Namespace

Drupal\Core\Mailer
View source
class TransportServiceFactory implements TransportServiceFactoryInterface {
    use TransportServiceFactoryTrait;
    
    /**
     * Constructs a new transport service factory.
     *
     * @param Iterable<TransportFactoryInterface> $factories
     *   A list of transport factories.
     * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
     *   The config factory service.
     */
    public function __construct(iterable $factories, ConfigFactoryInterface $configFactory) {
        $this->factories = $factories;
    }
    
    /**
     * {@inheritdoc}
     */
    public function createTransport() : TransportInterface {
        $dsn = $this->configFactory
            ->get('system.mail')
            ->get('mailer_dsn');
        $dsnObject = new Dsn(...$dsn);
        return $this->fromDsnObject($dsnObject);
    }

}

Members

Title Sort descending Modifiers Object type Summary
TransportServiceFactory::createTransport public function
TransportServiceFactory::__construct public function Constructs a new transport service factory.
TransportServiceFactoryTrait::$factories protected property A list of transport factories.
TransportServiceFactoryTrait::fromDsnObject protected function Constructs a transport instance given a DSN object.

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