class TransportInfoController

Returns responses for transport info routes.

Hierarchy

Expanded class hierarchy of TransportInfoController

File

core/modules/mailer/tests/modules/mailer_transport_factory_functional_test/src/Controller/TransportInfoController.php, line 17

Namespace

Drupal\mailer_transport_factory_functional_test\Controller
View source
class TransportInfoController implements ContainerInjectionInterface {
  
  /**
   * Constructs a new transport info controller.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The config factory.
   * @param \Symfony\Component\Mailer\Transport\TransportInterface $transport
   *   The mailer transport.
   */
  public function __construct(protected ConfigFactoryInterface $configFactory, protected TransportInterface $transport) {
  }
  
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) : static {
    return new static($container->get(ConfigFactoryInterface::class), $container->get(TransportInterface::class));
  }
  
  /**
   * Returns info about the configured mailer dsn and the resulting transport.
   */
  public function transportInfo() : Response {
    $mailerDsn = $this->configFactory
      ->get('system.mail')
      ->get('mailer_dsn');
    return new JsonResponse([
      'mailerDsn' => $mailerDsn,
      'mailerTransportClass' => $this->transport::class,
    ]);
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
TransportInfoController::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
TransportInfoController::transportInfo public function Returns info about the configured mailer dsn and the resulting transport.
TransportInfoController::__construct public function Constructs a new transport info controller.

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