Files
kupshop/bundles/KupShop/KupShopBundle/Email/NewsletterSubscribeEmail.php
2025-08-02 16:30:27 +02:00

61 lines
1.6 KiB
PHP

<?php
namespace KupShop\KupShopBundle\Email;
class NewsletterSubscribeEmail extends BaseEmail
{
protected static $name = 'Přihlášení k newsletteru';
protected static $type = 'NEWSLETTER_SUBSCRIBE';
protected static $priority = 0;
protected $subject = 'Přihlášení k odběru novinek';
protected $template = 'email/email_newsletter_subscribe.tpl';
protected $email;
public function testEmail(): array
{
$this->setEmail('test@email.cz');
return parent::testEmail();
}
public static function getPlaceholders()
{
$placeholders = [
'EMAIL_UZIVATELE' => [
'text' => 'E-mail uživatele',
],
'OVEROVACI_ADRESA' => [
'text' => 'Ověřovací adresa',
],
];
return [self::$type => $placeholders] + (parent::getPlaceholders() ?? []);
}
public function replacePlaceholdersItem($placeholder)
{
if ($this->email) {
switch ($placeholder) {
case 'OVEROVACI_ADRESA':
$today = new \DateTime();
$today = $today->format('d.m.Y');
$code = md5($this->email.'-'.$today);
return path('kupshop_content_newsletter_subscribe', ['code' => $code, 'email' => $this->email], 0);
case 'EMAIL_UZIVATELE':
return $this->email;
break;
}
}
return parent::replacePlaceholdersItem($placeholder);
}
public function setEmail($email)
{
$this->email = $email;
}
}