TYPO3 Flow Base DistributionPackagesApplications

Task #25477

What scope to use for Mailer and Transport?

Added by Karsten Dambekalns over 4 years ago. Updated about 3 years ago.

Status:Resolved Start date:2011-03-30
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:-
Target version:-

Description

I also don't quite get why the mailer and transport need to be of scope prototype.
Most commonly one would re-use the mailer and transport in the system.

Most commonly, yes. But...

Mailer and Transport are prototype (also in the original SwiftMailer code, despite the useless newInstance() method they have) because you might want to send mails using different transport mechanisms during one request. Since the transport is given to the mailer as constructor argument, the mailer must also be prototype for this to work.

Granted, currently there is only configuration for one default possible through SwiftMailer's Settings.yaml, but it is indeed possible to create another transport and mailer manually to send a message. If we switched to singleton scope, that would be confusing to say the least, and impossible in the worst case.

History

#1 Updated by Bastian Waidelich about 3 years ago

Sometimes you definitely need multiple instances. IMO this ticket can be closed

#2 Updated by Karsten Dambekalns about 3 years ago

  • Status changed from Needs Feedback to Resolved
  • % Done changed from 0 to 100

Right. Prototype it is and will be :)

Also available in: Atom PDF