<?php

namespace App\Resource\Repository;

use App\Resource\Entity\ResourcePool;
use App\Resource\Entity\ResourcePoolMember;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<ResourcePoolMember>
 */
class ResourcePoolMemberRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, ResourcePoolMember::class);
    }

    public function deleteForPool(ResourcePool $pool): int
    {
        return (int) $this->createQueryBuilder('m')
            ->delete()
            ->where('m.pool = :pool')
            ->setParameter('pool', $pool)
            ->getQuery()
            ->execute();
    }
}
