IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Can you extend a class created via factory?
The php Pear Mail class uses a factory to return an object based on the type of mail system you're using -- sendmail, smtp, etc.

I'd like to extend this but my class won't know what's being created by the Mail.php factory. Do I just need to copy the Mail.php factory method and modify that to use as my own factory? Does php allow extending a variable-named class? ie:
class List_Mail extends $class
--

Drew
New I'd be rethinking the algorithm at this point.
PHP's classes are quite classical in most ways. Dynamic inheritance is the province of prototyping languages, such as JavaScript.

Why do you need to modify the object that Pear::Mail returns? What does it need to do that it can't currently do?

You could create your own mail class which which either extends off Pear::Mail, or more likely stands outside it. You'd then need to build methods encapsulating how you want to call an email API and that does the calls to Pear::Mail. (I always end up doing this kind of thing for database access.)

Wade.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
New Need to add logging
I drop records in a queue saying "Send message 32 to user 495 at 11:00 AM on 2/24/2010". New records default their status to "pending".

When the queue processor runs, it grabs batches and updates status to "processing", then as it sends each one it changes the status to "sent", and sets the time that it was sent.

Right now, the "send" command is in a static lib, which instantiates the Mail class to send. So I'm creating a new instance for each message sent, which is typically 100 per run. I was thinking last night it would make more sense to extend the mail class instead, so there's just one instance, and just call the "send" method in the loop. I can also tie the status updates to the send method.

===

Hmm, just realized the PEAR guys had the same problem. The Mime class should really be an extension of the Mail class, but you can't make that work with the Mail factory.

I'll just keep my Message class static, and declare the Mail class static, too, so I don't keep recreating it.
--

Drew
Expand Edited by drook Jan. 30, 2010, 10:07:14 AM EST
Expand Edited by drook Jan. 30, 2010, 10:08:17 AM EST
New Sounds like you have a solution.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
     Can you extend a class created via factory? - (drook) - (3)
         I'd be rethinking the algorithm at this point. - (static) - (2)
             Need to add logging - (drook) - (1)
                 Sounds like you have a solution. -NT - (static)

No, you didn't. You came here for an argument!
82 ms