<?php

namespace App\Patient\Repository;

use App\Patient\Entity\SessionConsumable;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

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

    public function save(SessionConsumable $consumable): void
    {
        $this->getEntityManager()->persist($consumable);
        $this->getEntityManager()->flush();
    }

    public function remove(SessionConsumable $consumable, bool $flush = true): void
    {
        $this->getEntityManager()->remove($consumable);
        if ($flush) {
            $this->getEntityManager()->flush();
        }
    }
}
