<?php

declare(strict_types=1);

namespace App\Repository\Core;

use App\Entity\Core\File;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

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

    public function deleteByOrganization(int $organizationId): void
    {
        $this->createQueryBuilder('f')
            ->delete()
            ->where('f.organization = :organizationId')
            ->setParameter('organizationId', $organizationId)
            ->getQuery()
            ->execute();
    }

    public function deleteByPerson(int $personId): void
    {
        $this->createQueryBuilder('f')
            ->delete()
            ->where('f.person = :personId')
            ->setParameter('personId', $personId)
            ->getQuery()
            ->execute();
    }
}
