Hi Nicolas,
Your proposal of
$email = new sfEmail();
// then
$email->setHtmlTemplate(new sfEmailTemplateAction('mymodule','myaction');
// or
$email->setTextTemplate(new sfEmailTemplatePartial('mymodule', 'mypartial');
// or
$email->setTextTemplate(new sfEmailTemplateComponent('mymodule',
'mycomponent');
// or
$email->setTextTemplate(new sfEmailTemplateString('hello world'));
// and maybe
$email->setTemplate('text/html', new sfEmailTemplateString('hello world'));
// why not
$email->setTemplate('application/pdf', new
sfEmailTemplateFile('/tmp/toto.pdf');
// there could be also sfEmailTemplateCallback() and so on
// then
$email->send();
Is powerful but quite verbose. A slightly less verbose way would be to
use class constants, with sensible defaults. Plus the method names
(`setTextTemplate`) are less familiar than names referring to email
parts like `setBody()`:
$email = new sfEmail();
// then
$email->setHtmlBody('mymodule/myaction', sfEmail::ACTION);
// or
$email->setBody('mymodule/mypartial', sfEmail::PARTIAL);
// or
$email->setBody('mymodule/mycomponent', sfEmail::COMPONENT);
// or
$email->setBody('hello world'); // sfEmail::STRING is default
// and maybe
$email->setBodyPart('text/html', '<p>hello world</p>', sfEmail::STRING);
// why not
$email->setBodyPart('application/pdf', '/tmp/toto.pdf', sfEmail::FILE);
// there could be also sfEmail::CALLBACK and so on
But in the long run, this is still too much verbose, since it's longer
to learn and write than something much more natural:
$email = new sfEmail();
// then
$email->setHtmlBody(get_action('mymodule/myaction')); // well,
get_action() is still to be written...
// or
$email->setBody(get_partial('mymodule/mypartial'));
// or
$email->setBody(get_component('mymodule/mycomponent'));
// or
$email->setBody('hello world');
// and maybe
$email->setBodyPart('text/html', '<p>hello world</p>');
// why not
$email->setBodyPart('application/pdf', file_get_contents('/tmp/toto.pdf'));
// there could be also call_user_func() and so on
So my question is: Shouldn't we work on a reusable syntax for
get_partial() that is more OO and that could be learnt once and
injected everywhere, rather than introducing many new classes that
will only contain a few lines of code but that may prove longer to
learn?
My 2c.
François
2008/9/17 Nicolas Perriault <[EMAIL PROTECTED]>:
>
> On Tue, Sep 16, 2008 at 8:42 PM, Bernhard Schussek <[EMAIL PROTECTED]> wrote:
>
>> I suggest that you create a wiki page where you describe possible use
>> cases of this plugin together with possible implementations (similar
>> to Francois' DDD :-)
>
> Good idea, I've just came up with this page:
> http://trac.symfony-project.org/wiki/RFC/1.2/email
>
> As usual, feel free to add some comments :)
>
> ++
>
> --
> Nicolas Perriault
> http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
> Phone: +33 660 92 08 67
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---