[Mailer] Allow register mailer configuration in xml format

This commit is contained in:
Konstantin Myakshin 2019-07-15 22:23:03 +03:00 committed by Fabien Potencier
parent 88575f01b7
commit 2f3b47a9e4
5 changed files with 35 additions and 1 deletions

View File

@ -33,6 +33,7 @@
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
<xsd:element name="http-client" type="http_client" minOccurs="0" maxOccurs="1" />
<xsd:element name="mailer" type="mailer" minOccurs="0" maxOccurs="1" />
</xsd:choice>
<xsd:attribute name="http-method-override" type="xsd:boolean" />
@ -543,4 +544,8 @@
<xsd:complexType name="http_header" mixed="true">
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="mailer">
<xsd:attribute name="dsn" type="xsd:string" />
</xsd:complexType>
</xsd:schema>

View File

@ -0,0 +1,7 @@
<?php
$container->loadFromExtension('framework', [
'mailer' => [
'dsn' => 'smtp://example.com',
],
]);

View File

@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:mailer dsn="smtp://example.com" />
</framework:config>
</container>

View File

@ -0,0 +1,3 @@
framework:
mailer:
dsn: 'smtp://example.com'

View File

@ -55,7 +55,6 @@ use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Workflow;
abstract class FrameworkExtensionTest extends TestCase
@ -1552,6 +1551,14 @@ abstract class FrameworkExtensionTest extends TestCase
], $defaultOptions['peer_fingerprint']);
}
public function testMailer(): void
{
$container = $this->createContainerFromFile('mailer');
$this->assertTrue($container->hasAlias('mailer'));
$this->assertTrue($container->hasDefinition('mailer.default_transport'));
}
protected function createContainer(array $data = [])
{
return new ContainerBuilder(new ParameterBag(array_merge([