Skip to content

Commit 679d69a

Browse files
Kocfabpot
authored andcommitted
[Mailer] Allow register mailer configuration in xml format
1 parent eff0012 commit 679d69a

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

Resources/config/schema/symfony-1.0.xsd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
3434
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
3535
<xsd:element name="http-client" type="http_client" minOccurs="0" maxOccurs="1" />
36+
<xsd:element name="mailer" type="mailer" minOccurs="0" maxOccurs="1" />
3637
</xsd:choice>
3738

3839
<xsd:attribute name="http-method-override" type="xsd:boolean" />
@@ -543,4 +544,8 @@
543544
<xsd:complexType name="http_header" mixed="true">
544545
<xsd:attribute name="name" type="xsd:string" />
545546
</xsd:complexType>
547+
548+
<xsd:complexType name="mailer">
549+
<xsd:attribute name="dsn" type="xsd:string" />
550+
</xsd:complexType>
546551
</xsd:schema>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'mailer' => [
5+
'dsn' => 'smtp://example.com',
6+
],
7+
]);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:framework="http://symfony.com/schema/dic/symfony"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
8+
9+
<framework:config>
10+
<framework:mailer dsn="smtp://example.com" />
11+
</framework:config>
12+
</container>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
mailer:
3+
dsn: 'smtp://example.com'

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
5656
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
5757
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
58-
use Symfony\Component\Validator\Validation;
5958
use Symfony\Component\Workflow;
6059

6160
abstract class FrameworkExtensionTest extends TestCase
@@ -1552,6 +1551,14 @@ public function testHttpClientFullDefaultOptions()
15521551
], $defaultOptions['peer_fingerprint']);
15531552
}
15541553

1554+
public function testMailer(): void
1555+
{
1556+
$container = $this->createContainerFromFile('mailer');
1557+
1558+
$this->assertTrue($container->hasAlias('mailer'));
1559+
$this->assertTrue($container->hasDefinition('mailer.default_transport'));
1560+
}
1561+
15551562
protected function createContainer(array $data = [])
15561563
{
15571564
return new ContainerBuilder(new ParameterBag(array_merge([

0 commit comments

Comments
 (0)