| Current Path : /var/www/v3.cesa.co.za/src/ContactBundle/Command/ |
| Current File : /var/www/v3.cesa.co.za/src/ContactBundle/Command/SendNotificationsCommand.php |
<?php
namespace App\ContactBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use App\CoreBundle\Services\ServiceGetterManager;
/**
* Send Notifications Command
*
* @author Otto Saayman <otto@igotafrica.com>
* @package ContactBundle
* @subpackage Controller
* @version 0.0.1
*/
class SendNotificationsCommand extends Command {
private $serviceGetterManager;
public function __construct(ServiceGetterManager $serviceGetterManager) {
$this->serviceGetterManager = $serviceGetterManager;
parent::__construct();
}
protected function configure() {
$this
->setName('iga:message:notify')
->setDescription('Send notification e-mails daily')
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$_SERVER["HTTP_HOST"] = 'igotafrica.com';
$defaultSiteId = $this->serviceGetterManager->get('system_setting.manager')->getSetting('default_site_id');
$defaultSite = $this->serviceGetterManager->get('sites.manager')->find($defaultSiteId);
if (is_object($defaultSite)) {
$_SERVER["HTTP_HOST"] = $defaultSite->getSiteHostName();
}
$messageManager = $this->serviceGetterManager->get('contact_message.manager');
$mailCount = $messageManager->sendNotificationMails();
$output->writeln('Sent ' . $mailCount . ' notification mails');
return $mailCount;
}
}