<?php

namespace App\Sms\Repository;

use App\Sms\Entity\SmsMessageTemplate;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class SmsMessageTemplateRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, SmsMessageTemplate::class);
    }

    public function findByTag(string $tag): ?SmsMessageTemplate
    {
        return $this->findOneBy(['tag' => $tag]);
    }

    public function save(SmsMessageTemplate $entity, bool $flush = true): void
    {
        $this->getEntityManager()->persist($entity);
        if ($flush) {
            $this->getEntityManager()->flush();
        }
    }
}
