Re-open the same ticket if a ticket already exists with the same externalRef, instead of creating a new one

This commit is contained in:
2024-04-24 18:48:00 +02:00
parent 45828174d1
commit 2d8b960d9e
4 changed files with 95 additions and 3 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\TicketBundle\Repository;
use Chill\TicketBundle\Entity\Ticket;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectRepository;
final readonly class TicketRepository implements TicketRepositoryInterface
{
private ObjectRepository $repository;
public function __construct(EntityManagerInterface $objectManager)
{
$this->repository = $objectManager->getRepository($this->getClassName());
}
public function find($id): ?Ticket
{
return $this->repository->find($id);
}
public function findAll(): array
{
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria): ?Ticket
{
return $this->repository->findOneBy($criteria);
}
public function getClassName()
{
return Ticket::class;
}
public function findOneByExternalRef(string $extId): ?Ticket
{
return $this->repository->findOneBy(['externalRef' => $extId]);
}
}