<?php

namespace App\Repository;

use App\Entity\HorairePassage;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<MomentPassage>
 *
 * @method HorairePassage|null find($id, $lockMode = null, $lockVersion = null)
 * @method HorairePassage|null findOneBy(array $criteria, array $orderBy = null)
 * @method HorairePassage[]    findAll()
 * @method HorairePassage[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class HorairePassageRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, HorairePassage::class);
    }

    /**
     * @throws ORMException
     * @throws OptimisticLockException
     */
    public function add(HorairePassage $entity, bool $flush = true): void
    {
        $this->_em->persist($entity);
        if ($flush) {
            $this->_em->flush();
        }
    }

    /**
     * @throws ORMException
     * @throws OptimisticLockException
     */
    public function remove(HorairePassage $entity, bool $flush = true): void
    {
        $this->_em->remove($entity);
        if ($flush) {
            $this->_em->flush();
        }
    }
}
