catalyzRelanceTask.class.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. class catalyzRelanceTask extends sfPropelBaseTask {
  3. protected function configure()
  4. {
  5. $this->namespace = 'catalyz';
  6. $this->name = 'relance';
  7. $this->briefDescription = '';
  8. $this->detailedDescription = <<<EOF
  9. The [catalyz:import|INFO] task does things.
  10. Call it with:
  11. [php symfony catalyz:relance|INFO]
  12. EOF;
  13. $this->addArgument('application', sfCommandArgument::OPTIONAL, 'The application name', 'frontend');
  14. // add other arguments here
  15. $this->addOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'af');
  16. $this->addOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel');
  17. // add other options here
  18. }
  19. protected function execute($arguments = array(), $options = array())
  20. {
  21. // Database initialization
  22. $databaseManager = new sfDatabaseManager($this->configuration);
  23. $connection = Propel::getConnection($options['connection'] ? $options['connection'] : '');
  24. $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'af', true);
  25. sfContext::createInstance($configuration);
  26. sfLoader::loadHelpers('Partial');
  27. $criteria = new Criteria();
  28. $lists = KataoUserPeer::doSelect($criteria);
  29. $destinatairesList = array();
  30. foreach ($lists as $list) {
  31. $destinatairesList[]= $list->getEmail();
  32. }
  33. // $destinatairesList = array('ferrere.arnaud@gmail.com','af@catalyz.fr');
  34. var_dump($destinatairesList);
  35. die();
  36. try {
  37. $recipients = new Swift_RecipientList();
  38. $recipients->addTo($destinatairesList);
  39. // $recipients->addBcc('sh@catalyz.fr');
  40. /*
  41. * Instanciation du mailer et du message
  42. */
  43. $mailer = new Swift(new Swift_Connection_NativeMail());
  44. $message = new Swift_Message('Relance', get_partial('katao/relanceEmail'), 'text/html');
  45. /*
  46. * Envoi
  47. */
  48. $mailer->send($message, $recipients, 'no-reply@sol-violette.fr');
  49. $mailer->disconnect();
  50. }
  51. catch (Exception $e) {
  52. // Gestion des erreurs ici
  53. $mailer->disconnect();
  54. var_dump($e->getMessage());
  55. die();
  56. }
  57. }
  58. }