<?php

namespace App\Repository\EventLogContent;

use App\Entity\EventLogContent;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;

final class DoctrineEventLogContentRepository extends ServiceEntityRepository implements EventLogContentRepositoryInterface
{
    public function __construct(RegistryInterface $registry)
    {
        parent::__construct($registry, EventLogContent::class);
    }

    public function findById(int $id): ?EventLogContent
    {
        return $this->findOneBy(['id' => $id]);
    }

    /**
     * @param EventLogContent $eventLogContent
     *
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function save(EventLogContent $eventLogContent): void
    {
        $this->_em->persist($eventLogContent);
        $this->_em->flush();
    }

    /**
     * @param EventLogContent $eventLogContent
     *
     * @throws \Doctrine\ORM\ORMException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function delete(EventLogContent $eventLogContent): void
    {
        $this->_em->remove($eventLogContent);
        $this->_em->flush();
    }
}
