Here 's some code of mine, although I use it on sf1.1. It should work
on 1.2 as far as I know
<?php
class resetPasswordTask extends sfPropelBaseTask
{
protected function configure()
{
$this->namespace = 'send';
$this->name = 'resetPassword';
$this->briefDescription = 'Send reset password emails';
$this->detailedDescription = <<<EOF
The [send_confirmation|INFO] task does things.
Call it with:
[php symfony send_confirmation|INFO]
EOF;
$this->addArgument('application', sfCommandArgument::REQUIRED,
'The application name');
// add other arguments here
$this->addOption('env', null, sfCommandOption::PARAMETER_REQUIRED,
'The environment', 'dev');
$this->addOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel');
// add other options here
}
protected function execute($arguments = array(), $options = array())
{
// Database initialization
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = Propel::getConnection($options['connection'] ?
$options['connection'] : '');
// you need a context to load the partial helper
$context = sfContext::createInstance($this->configuration);
sfLoader::loadHelpers('Partial');
...
while ($activation_count > 0 AND $sent < $max_sent)
{
...
$mailbody = get_partial ('mailer/resetPassword',
array('activation'
=> $activation));
...
}
}
}
On Mar 4, 1:34 pm, danielwinter <[email protected]> wrote:
> Wanting to send emails using templates from a CLI task.The cookbook
> says:
>
> "You'll need to use get_partial() and get_component() functions in
> PartialHelper instead of sfAction::getPartial() and
> sfAction::getComponent() methods."
>
> But has anyone actually got this to work?!?!
> cheers
> dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---