58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\HannahBundle\Email;
|
|
|
|
use KupShop\KupShopBundle\Email\EmailGroupTypeEnum;
|
|
use KupShop\KupShopBundle\Email\PasswordResetAdminEmail;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
use KupShop\OrderingBundle\Util\Attachment\AttachmentLocator;
|
|
|
|
abstract class OCRegistrationEmail extends PasswordResetAdminEmail
|
|
{
|
|
public function renderEmail($message, $data = [], $base_template = 'other.tpl'): array
|
|
{
|
|
$email = parent::renderEmail($message, $data, $base_template);
|
|
|
|
$email['template'] = $message;
|
|
|
|
return $email;
|
|
}
|
|
|
|
public function getAttachments($template): array
|
|
{
|
|
if (empty($template['attachments']) || !$this->user) {
|
|
return [];
|
|
}
|
|
|
|
$result = [];
|
|
|
|
$locator = ServiceContainer::getService(AttachmentLocator::class);
|
|
|
|
$attachments = $locator->getAttachments(EmailGroupTypeEnum::OTHER);
|
|
$types = json_decode($template['attachments'] ?: '', true) ?: [];
|
|
foreach ($types as $type) {
|
|
if (!($attachments[$type] ?? false)) {
|
|
continue;
|
|
}
|
|
|
|
$attachment = $locator->getServiceByType($type, new \Order());
|
|
|
|
if (method_exists($attachment, 'setUser')) {
|
|
$attachment->setUser($this->user);
|
|
}
|
|
|
|
$data = $attachment->getAttachment();
|
|
|
|
$result[] = [
|
|
'filename' => $attachment->getFilename(),
|
|
'type' => $attachment->getAttachmentType(),
|
|
$data['attachment_type'] => $data['attachment'],
|
|
];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|