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

Allow multilple delivery_address addresses #121

Merged
merged 1 commit into from
Jan 14, 2016

Conversation

jorns
Copy link
Contributor

@jorns jorns commented Dec 9, 2015

No description provided.

@jorns jorns force-pushed the multiple_delivery_adresses branch from ef4d71c to a981458 Compare December 9, 2015 17:59
@@ -66,6 +66,10 @@
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="delivery-address">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Build fails due to this update. Won't fail after it's published on http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd.

Copy link
Member

Choose a reason for hiding this comment

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

this is not true. Symfony uses the local schema. the issue is that you defined a custom type, but you never use it

@jorns jorns force-pushed the multiple_delivery_adresses branch 2 times, most recently from dc131e4 to 04179c0 Compare December 9, 2015 21:33
@jorns
Copy link
Contributor Author

jorns commented Dec 9, 2015

Solves #99

@@ -112,6 +112,14 @@ private function getMailersNode()
->end()
->scalarNode('sender_address')->end()
->scalarNode('delivery_address')->end()
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed anymore with the fixXmlConfig() call.

Copy link
Member

Choose a reason for hiding this comment

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

and then you should check below if the passed value isn't an array (and cast it then)

@jorns jorns force-pushed the multiple_delivery_adresses branch 2 times, most recently from 8cec8f1 to 63c3427 Compare December 9, 2015 22:27
@jorns
Copy link
Contributor Author

jorns commented Dec 11, 2015

@stof can you look over it again?

->arrayNode('delivery_addresses')
->beforeNormalization()
->always()
->then(function ($v) { return array_values((array) $v); })
Copy link
Member

Choose a reason for hiding this comment

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

You don't have to make that change, when the value already is an array:

// ...
->beforeNormalization()
    ->ifString()
    ->then(function ($v) { return (array) $v; })
->end()

// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

array_values normalizes the keys so I can use

$mailer['delivery_addresses'][0]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xabbuh, so what do you think? Is it still a problem for you?

Copy link
Member

Choose a reason for hiding this comment

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

I do not see how you would get keys that are not normalised without this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is possible with a config like:

delivery_addresses: { a: [email protected], b: [email protected] }

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't something like this be forbidden given that we have a scalar prototype here?

Copy link
Member

Choose a reason for hiding this comment

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

@xabbuh there is a long-standing bug in the Config component (but fixing it is a BC break, and I forogt it when we worked on 3.0, missing the opportunity for this): lists are reindexed numerically for prototyped nodes only when 2 configs need to be merged together. But if only 1 file is configuring it, we don't call array_values to reset keys.

Copy link
Member

Choose a reason for hiding this comment

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

@stof Too bad, then let's keep it as is.

@jorns jorns force-pushed the multiple_delivery_adresses branch from 63c3427 to 9968c18 Compare December 15, 2015 15:48
@jorns
Copy link
Contributor Author

jorns commented Dec 15, 2015

@xabbuh @stof, thanks for the feedback. Updated!

@jvandesande
Copy link

+1

@lokhman
Copy link

lokhman commented Dec 21, 2015

This feature is very much required as so far I don't see any possible way to set up more than one recipient, which is essential for development and testing.

@fabpot
Copy link
Member

fabpot commented Jan 14, 2016

Thank you @jorns.

@fabpot fabpot merged commit 9968c18 into symfony:master Jan 14, 2016
fabpot added a commit that referenced this pull request Jan 14, 2016
This PR was merged into the 2.3-dev branch.

Discussion
----------

Allow multilple delivery_address addresses

Commits
-------

9968c18 Allow multilple delivery_address addresses
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.

6 participants