10000 Support setLocalDomain() and setStreamOptions() by c960657 · Pull Request #141 · symfony/swiftmailer-bundle · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Support setLocalDomain() and setStreamOptions() #141

Closed
wants to merge 3 commits into from
Closed

Support setLocalDomain() and setStreamOptions() #141

wants to merge 3 commits into from

Conversation

c960657
Copy link
Contributor
@c960657 c960657 commented May 14, 2016

This PR adds support for Swift_Transport_AbstractSmtpTransport::setLocalDomain() and Swift_Transport_EsmtpTransport::setStreamOptions().

@c960657
Copy link
Contributor Author
c960657 commented Sep 11, 2016

The PHP 7 build fails on Travis because phpunit/phpunit-mock-objects versions 3.2.4 and 3.2.5 are broken. I don't know how to upgrade this package on Travis.


public function configureLocalDomain(\Swift_Transport_AbstractSmtpTransport $transport)
{
if ($this->requestContext) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you explicitly set a localDomain, I expect it to have priority over anything else, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

@@ -14,6 +14,7 @@
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler\RegisterPluginsPass;
use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler\RegisterHostnamePass;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it can be reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

$container
->setDefinition(sprintf('swiftmailer.configurator.transport.%s', $name), $configuratorDecorator)
->setArguments(array(
'%swiftmailer.mailer.' . $name . '.transport.smtp.local_domain%',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony CS does not use spaces around dots, and in such situations, we prefer to use sprintf (the same goes in different places in this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

$this->requestContext = $requestContext;
}

public function configureLocalDomain(\Swift_Transport_AbstractSmtpTransport $transport)
Copy link
Member

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?

Copy link
Contributor Author

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 becomes AbstractSmtpConfigurator::configure(). Ok?

@@ -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>
Copy link
Member

Choose a reason for hiding this comment

The 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

@fabpot
Copy link
Member
fabpot commented Oct 19, 2016

👍 (when my 2 small comments are adressed)

/**
* Service configurator.
*/
class AbstractSmtpTransportConfigurator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it called abstract? It should be removed as I would expect the class to be abstract, which it is not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it configures subclasses of Swift_Transport_AbstractSmtpTransport. But I get your point, so I have stripped the Abstract prefix.


/**
* Service configurator.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

{
/**
* @var string
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. But why? The coding guidelines on http://symfony.com/doc/current/contributing/code/standards.html does not go into much detail about PHPdoc, but it does include an example of a @var used together with a private variable.

/**
* @var string
*/
protected $localDomain;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be private

/**
* @var RequestContext
*/
protected $requestContext;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be private


/**
* @var RequestContext
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

* Sets the local domain based on the current request context.
*
* @param string $localDomain Fallback value if there is no request context.
* @param RequestContext $requestContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

protected $requestContext;

/**
* Sets the local domain based on the current request context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is probably more appropriate for the configure method.

@fabpot
Copy link
Member
fabpot commented Oct 27, 2016

Thank you @c960657.

@fabpot fabpot closed this in 287d37f Oct 27, 2016
@c960657 c960657 deleted the localdomain-streamoptions branch November 4, 2016 13:41
xabbuh added a commit to xabbuh/symfony-docs that referenced this pull request Apr 30, 2017
* The `url` option was added in version 2.3.10 of the SwiftmailerBundle
  (see symfony/swiftmailer-bundle#118).
* The `timeout` and `source_ip` options are part of SwiftmailerBundle
  since symfony/swiftmailer-bundle#14 which was part of the 2.1.0
  release.
* The `local_domain` option was first included in the 2.4.0 release (see
  symfony/swiftmailer-bundle#141).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0