/home/sharedstore/public_html/prestashop.sharedstore.ma/src/Adapter/Email
Edit: /home/sharedstore/public_html/prestashop.sharedstore.ma/src/Adapter/Email/EmailLogEraser.php (2563B)
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
namespace PrestaShop\PrestaShop\Adapter\Email;
use PrestaShop\PrestaShop\Adapter\Entity\Mail;
use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopCollection;
use PrestaShop\PrestaShop\Core\Email\EmailLogEraserInterface;
/**
* Class EmailLogEraser provides API for erasing email logs.
*
* @internal
*/
final class EmailLogEraser implements EmailLogEraserInterface
{
/**
* {@inheritdoc}
*/
public function erase(array $mailLogIds)
{
$errors = [];
if (empty($mailLogIds)) {
$errors[] = [
'key' => 'You must select at least one element to delete.',
'parameters' => [],
'domain' => 'Admin.Notifications.Error',
];
return $errors;
}
$emailLogs = new PrestaShopCollection('Mail');
$emailLogs->where('id_mail', 'in', $mailLogIds);
/** @var Mail $emailLog */
foreach ($emailLogs->getResults() as $emailLog) {
if (!$emailLog->delete()) {
$errors[] = [
'key' => 'Can\'t delete #%id%',
'parameters' => [
'%id%' => $emailLog->id,
],
'domain' => 'Admin.Notifications.Error',
];
continue;
}
}
return $errors;
}
/**
* {@inheritdoc}
*/
public function eraseAll()
{
return Mail::eraseAllLogs();
}
}