<?php declare(strict_types=1);
namespace Virgin\EmailPlugin;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateType\MailTemplateTypeEntity;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class EmailPlugin extends Plugin
{
public function install(InstallContext $installContext): void
{
// //get the Templates and Associations from the DB
// /** @var EntityRepositoryInterface $mailTemplateTypeRepository */
// $mailTemplateTypeRepository = $this->container->get('mail_template_type.repository');
// /** @var EntityRepositoryInterface $mailTemplateRepository */
// $mailTemplateRepository = $this->container->get('mail_template.repository');
//
// $customMailTemplates = $mailTemplateRepository->search(
// (new Criteria())
// ->addFilter(new EqualsFilter('systemDefault', 0)),
// $installContext
// ->getContext()
// )->getElements();
//
// foreach ($customMailTemplates as $customMailTemplate){
// /** @var MailTemplateTypeEntity $customMailTemplateType */
// $customMailTemplateType = $mailTemplateTypeRepository->search(
// (new Criteria())
// ->addFilter(new EqualsFilter('id', $customMailTemplate->getMailTemplateTypeId())),
// $installContext
// ->getContext()
// )->first();
// //Delete the custom Templates
// $mailTemplateRepository->delete([['id' => $customMailTemplate->getId()]], $installContext->getContext());
//
// //Delete the custom TemplateType
// $mailTemplateTypeRepository->delete([
// ['id' => $customMailTemplateType->getId()]
// ], $installContext->getContext());
// }
// parent::install($installContext);
}
}