Your IP : 127.0.0.1
<?php
/*
NOTICE OF LICENSE
This source file is subject to the NekloEULA that is bundled with this package in the file ICENSE.txt.
It is also available through the world-wide-web at this URL: http://store.neklo.com/LICENSE.txt
Copyright (c) Neklo (http://store.neklo.com/)
*/
namespace Neklo\LowStockNotification\Mail;
use Magento\Framework\Data\Collection;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\MailException;
use Neklo\Core\Mail\Sender;
use Neklo\LowStockNotification\Helper\Config;
class CronNotifier
{
/**
* Template Identifier
*/
const TEMPLATE_ID = 'neklo_lowstocknotification_notification_cron_email_template';
/**
* @var Sender
*/
private $sender;
/**
* @var Config
*/
private $config;
/**
* @param Sender $sender
* @param Config $config
*/
public function __construct(Sender $sender, Config $config)
{
$this->sender = $sender;
$this->config = $config;
}
/**
* @param Collection $rows
*
* @return void
* @throws LocalizedException
* @throws MailException
*/
public function execute(Collection $rows)
{
$emails = $this->config->getEmailList();
$sender = $this->config->getEmailSender();
if (!empty($emails) && $sender && $rows->count()) {
$variables = [
'rows' => $rows,
];
foreach ($emails as $email) {
$this->sender->execute(self::TEMPLATE_ID, $sender, $email, $variables);
}
}
}
}