feat: admin editable email templates
addresses #869eg7ptr
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Config\EmailTextKey;
|
||||
use App\Entity\EmailText;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<EmailText>
|
||||
*
|
||||
* @method EmailText|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method EmailText|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method EmailText[] findAll()
|
||||
* @method EmailText[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class EmailTextRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EmailText::class);
|
||||
}
|
||||
|
||||
public function findByKey(EmailTextKey $key): ?EmailText
|
||||
{
|
||||
return $this->findOneBy(['templateKey' => $key->value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, EmailText> keyed by EmailTextKey value
|
||||
*/
|
||||
public function findAllIndexedByKey(): array
|
||||
{
|
||||
$indexed = [];
|
||||
|
||||
foreach ($this->findAll() as $emailText) {
|
||||
$indexed[$emailText->getTemplateKey()] = $emailText;
|
||||
}
|
||||
|
||||
return $indexed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user