Skip to content

Commit af0c2e4

Browse files
feat: store mail template id (#140)
1 parent 48b7a71 commit af0c2e4

25 files changed

Lines changed: 139 additions & 30 deletions

‎src/Content/MailArchive/MailArchiveDefinition.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Shopware\Core\Checkout\Customer\CustomerDefinition;
88
use Shopware\Core\Checkout\Order\OrderDefinition;
99
use Shopware\Core\Content\Flow\FlowDefinition;
10+
use Shopware\Core\Content\MailTemplate\MailTemplateDefinition;
1011
use Shopware\Core\Defaults;
1112
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
1213
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
@@ -75,6 +76,9 @@ protected function defineFields(): FieldCollection
7576
new FkField('flow_id', 'flowId', FlowDefinition::class),
7677
new ManyToOneAssociationField('flow', 'flow_id', FlowDefinition::class, 'id', false),
7778

79+
new FkField('mail_template_id', 'mailTemplateId', MailTemplateDefinition::class),
80+
new ManyToOneAssociationField('mailTemplate', 'mail_template_id', MailTemplateDefinition::class, 'id', false),
81+
7882
new FkField('source_mail_id', 'sourceMailId', self::class),
7983
new ManyToOneAssociationField('sourceMail', 'source_mail_id', self::class, 'id', false),
8084
new OneToManyAssociationField('sourceMails', self::class, 'sourceMailId'),

‎src/Content/MailArchive/MailArchiveEntity.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Shopware\Core\Checkout\Customer\CustomerEntity;
88
use Shopware\Core\Checkout\Order\OrderEntity;
99
use Shopware\Core\Content\Flow\FlowEntity;
10+
use Shopware\Core\Content\MailTemplate\MailTemplateEntity;
1011
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
1112
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
1213
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
@@ -68,6 +69,10 @@ class MailArchiveEntity extends Entity
6869
*/
6970
protected ?EntityCollection $sourceMails = null;
7071

72+
protected ?string $mailTemplateId = null;
73+
74+
protected ?MailTemplateEntity $mailTemplate = null;
75+
7176
/**
7277
* @return array<string, string>
7378
*/
@@ -291,4 +296,24 @@ public function setOrderVersionId(?string $orderVersionId): void
291296
{
292297
$this->orderVersionId = $orderVersionId;
293298
}
299+
300+
public function getMailTemplateId(): ?string
301+
{
302+
return $this->mailTemplateId;
303+
}
304+
305+
public function setMailTemplateId(?string $mailTemplateId): void
306+
{
307+
$this->mailTemplateId = $mailTemplateId;
308+
}
309+
310+
public function getMailTemplate(): ?MailTemplateEntity
311+
{
312+
return $this->mailTemplate;
313+
}
314+
315+
public function setMailTemplate(?MailTemplateEntity $mailTemplate): void
316+
{
317+
$this->mailTemplate = $mailTemplate;
318+
}
294319
}

‎src/Controller/Api/MailArchiveController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function __construct(
4343
private readonly AbstractMailSender $mailSender,
4444
private readonly RequestStack $requestStack,
4545
private readonly EmlFileManager $emlFileManager,
46-
) {}
46+
) {
47+
}
4748

4849
#[Route(path: '/api/_action/frosh-mail-archive/resend-mail', name: 'api.action.frosh-mail-archive.resend-mail')]
4950
public function resend(Request $request, Context $context): JsonResponse

‎src/Migration/Migration1598204175SenderToJson.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ public function update(Connection $connection): void
2121
CHANGE `sender` `sender` json NOT NULL AFTER `id`;');
2222
}
2323

24-
public function updateDestructive(Connection $connection): void {}
24+
public function updateDestructive(Connection $connection): void
25+
{
26+
}
2527
}

‎src/Migration/Migration1690743548AddEmlPath.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ public function update(Connection $connection): void
2020
ADD `eml_path` varchar(2048) NULL;');
2121
}
2222

23-
public function updateDestructive(Connection $connection): void {}
23+
public function updateDestructive(Connection $connection): void
24+
{
25+
}
2426
}

‎src/Migration/Migration1691326842Attachment.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ public function update(Connection $connection): void
3131
');
3232
}
3333

34-
public function updateDestructive(Connection $connection): void {}
34+
public function updateDestructive(Connection $connection): void
35+
{
36+
}
3537
}

‎src/Migration/Migration1694604822AddSourceMailId.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public function update(Connection $connection): void
1919
$connection->executeStatement('ALTER TABLE `frosh_mail_archive` ADD `source_mail_id` BINARY(16) NULL;');
2020
}
2121

22-
public function updateDestructive(Connection $connection): void {}
22+
public function updateDestructive(Connection $connection): void
23+
{
24+
}
2325
}

‎src/Migration/Migration1694714751TransportInfo.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public function update(Connection $connection): void
1919
$connection->executeStatement('ALTER TABLE `frosh_mail_archive` ADD `transport_state` VARCHAR(255) NULL;');
2020
}
2121

22-
public function updateDestructive(Connection $connection): void {}
22+
public function updateDestructive(Connection $connection): void
23+
{
24+
}
2325
}

‎src/Migration/Migration1707002823DropEmlFiled.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public function update(Connection $connection): void
1919
$connection->executeStatement('ALTER TABLE `frosh_mail_archive` DROP COLUMN `eml`');
2020
}
2121

22-
public function updateDestructive(Connection $connection): void {}
22+
public function updateDestructive(Connection $connection): void
23+
{
24+
}
2325
}

‎src/Migration/Migration1713775973AlterSubjectFieldLength.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public function update(Connection $connection): void
1919
$connection->executeStatement('ALTER TABLE `frosh_mail_archive` MODIFY `subject` VARCHAR(998) NOT NULL;');
2020
}
2121

22-
public function updateDestructive(Connection $connection): void {}
22+
public function updateDestructive(Connection $connection): void
23+
{
24+
}
2325
}

0 commit comments

Comments
 (0)