Add Zend\Mail\Transport\Factory #5470

Merged
merged 5 commits into from Nov 13, 2013

Conversation

Projects
None yet
3 participants
Contributor

stefanotorresi commented Nov 13, 2013

No description provided.

@ThomasCantonnet ThomasCantonnet commented on the diff Nov 13, 2013

library/Zend/Mail/Transport/Factory.php
+ */
+ public static function create($spec = array())
+ {
+ if ($spec instanceof Traversable) {
+ $spec = ArrayUtils::iteratorToArray($spec);
+ }
+
+ if (! is_array($spec)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects an array or Traversable argument; received "%s"',
+ __METHOD__,
+ (is_object($spec) ? get_class($spec) : gettype($spec))
+ ));
+ }
+
+ $type = isset($spec['type']) ? $spec['type'] : 'sendmail';
@ThomasCantonnet

ThomasCantonnet Nov 13, 2013

Contributor

strtolower here instead of twice below?

@stefanotorresi

stefanotorresi Nov 13, 2013

Contributor

oops, i'll fix it right away!

@ThomasCantonnet ThomasCantonnet and 1 other commented on an outdated diff Nov 13, 2013

library/Zend/Mail/Transport/Factory.php
+ }
+
+ if (! is_array($spec)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects an array or Traversable argument; received "%s"',
+ __METHOD__,
+ (is_object($spec) ? get_class($spec) : gettype($spec))
+ ));
+ }
+
+ $type = isset($spec['type']) ? $spec['type'] : 'sendmail';
+
+ if (isset(static::$classMap[strtolower($type)])) {
+ $type = static::$classMap[strtolower($type)];
+ }
+
@ThomasCantonnet

ThomasCantonnet Nov 13, 2013

Contributor

since from your code it seems that one can choose a type outside the $classmap array (eg custom class implementing TransportInterface), wouldn't it make more sense to remove this array and use namespaces instead ?

@stefanotorresi

stefanotorresi Nov 13, 2013

Contributor

That would prevent to use shortands type values for transports classes supplied by the framework OOTB.
This behavior is meant to be consistent with other static factories present in the framework (i.e. Zend\Captcha\Factory)

@ThomasCantonnet

ThomasCantonnet Nov 13, 2013

Contributor

fair enough :)

@weierophinney weierophinney added a commit that referenced this pull request Nov 13, 2013

@weierophinney weierophinney Merge pull request #5470 from stefanotorresi/add/mail-transport-factory
Add Zend\Mail\Transport\Factory
b0e13c6

@weierophinney weierophinney added a commit that referenced this pull request Nov 13, 2013

@weierophinney weierophinney Merge branch 'feature/5470' into develop
Close #5470
2f2cf4f

@weierophinney weierophinney merged commit fa9617b into zendframework:develop Nov 13, 2013

1 check passed

default The Travis CI build passed
Details

stefanotorresi deleted the stefanotorresi:add/mail-transport-factory branch Nov 13, 2013

@weierophinney weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015

@weierophinney weierophinney Merge pull request zendframework/zendframework#5470 from stefanotorre…
…si/add/mail-transport-factory

Add Zend\Mail\Transport\Factory
bd9c008

@weierophinney weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015

@weierophinney weierophinney Merge branch 'feature/5470' into develop c7d5ecb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment