This repository was archived by the owner on Feb 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 154
Support setLocalDomain() and setStreamOptions() #141
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Routing\RequestContext; | ||
|
||
/** | ||
* Service configurator. | ||
*/ | ||
class Configurator | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $localDomain; | ||
|
||
/** | ||
* @var RequestContext | ||
*/ | ||
protected $requestContext; | ||
|
||
/** | ||
* Sets the local domain based on the current request context. | ||
* | ||
* @param string $localDomain Fallback value if there is no request context. | ||
* @param RequestContext $requestContext | ||
*/ | ||
public function __construct($localDomain, RequestContext $requestContext = null) | ||
{ | ||
$this->localDomain = $localDomain; | ||
$this->requestContext = $requestContext; | ||
} | ||
|
||
public function configureLocalDomain(\Swift_Transport_AbstractSmtpTransport $transport) | ||
{ | ||
if ($this->localDomain) { | ||
$transport->setLocalDomain($this->localDomain); | ||
} elseif ($this->requestContext) { | ||
$transport->setLocalDomain($this->requestContext->getHost()); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
<parameter key="swiftmailer.email_sender.listener.class">Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener</parameter> | ||
|
||
<parameter key="swiftmailer.data_collector.class">Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector</parameter> | ||
<parameter key="swiftmailer.configurator.class">Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Configurator</parameter> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't define class name as parameter anymore, so this one need to be inlined |
||
</parameters> | ||
|
||
<services> | ||
|
@@ -36,6 +37,8 @@ | |
|
||
<service id="swiftmailer.transport.sendmail.abstract" class="%swiftmailer.transport.sendmail.class%" abstract="true" public="false" /> | ||
|
||
<service id="swiftmailer.configurator.abstract" class="%swiftmailer.configurator.class%" abstract="true" public="false" /> | ||
|
||
<service id="swiftmailer.transport.mail.abstract" class="%swiftmailer.transport.mail.class%" abstract="true" public="false"> | ||
<argument type="service" id="swiftmailer.transport.mailinvoker" /> | ||
</service> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
'timeout' => '1000', | ||
'source_ip' => '127.0.0.1', | ||
'logging' => true, | ||
'local_domain' => 'local.example.org', | ||
)); |
15 changes: 15 additions & 0 deletions
15
Tests/DependencyInjection/Fixtures/config/php/stream_options.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
$container->loadFromExtension('swiftmailer', array( | ||
'transport' => 'smtp', | ||
'host' => 'example.org', | ||
'port' => '12345', | ||
'source_ip' => '127.0.0.1', | ||
'stream_options' => array( | ||
'ssl' => array( | ||
'verify_peer' => true, | ||
'verify_depth' => 5, | ||
'cafile' => '/etc/ssl/cacert.pem', | ||
'CN_match' => 'ssl.example.com', | ||
), | ||
), | ||
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
|
||
<swiftmailer:config | ||
transport="sendmail" | ||
local-domain="local.example.org" | ||
/> | ||
</container> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Tests/DependencyInjection/Fixtures/config/xml/stream_options.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd"> | ||
|
||
<swiftmailer:config | ||
transport="smtp" | ||
host="example.org" | ||
port="12345" | ||
source-ip="127.0.0.1"> | ||
<swiftmailer:stream-options> | ||
<swiftmailer:stream-option name="ssl"> | ||
<swiftmailer:stream-option name="verify_peer">true</swiftmailer:stream-option> | ||
<swiftmailer:stream-option name="verify_depth">5</swiftmailer:stream-option> | ||
<swiftmailer:stream-option name="cafile">/etc/ssl/cacert.pem</swiftmailer:stream-option> | ||
<swiftmailer:stream-option name="CN_match">ssl.example.com</swiftmailer:stream-option> | ||
</swiftmailer:stream-option> | ||
</swiftmailer:stream-options> | ||
</swiftmailer:config> | ||
</container> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about renaming if to just
configure
, so that we can use this for other things in the future if needed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the method name is
Configurator::configure()
, there is no obvious name to use if we some day want to configure other classes. So I have also changed the class name, so the method name becomesAbstractSmtpConfigurator::configure()
. Ok?