addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), )); $this->namespace = 'jobs'; $this->name = 'sendMailsForExpirations'; $this->briefDescription = 'Rozesle upozorneni na koncici inzeraty.'; $this->detailedDescription = ''; } protected function execute($arguments = array(), $options = array()) { sfContext::createInstance($this->configuration); $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $this->configuration->loadHelpers(array('Partial')); $query = Doctrine::getTable('Job')->getPreExpirationQuery(); foreach($query->execute() as $job) { if($job->hasProfile()) { $this->getMailer()->composeAndSend( sfConfig::get('app_mail_from_address'), $job->getProfile()->getMail(), 'Ukončení platnoti inzerátu | '.sfConfig::get('app_title'), get_component('jobs', 'expirationJobMailBody', array('job' => $job)) ); $this->logSection('send-mail', 'job_id='.$job->getId().', mail:'.$job->getProfile()->getMail()); } } } }