mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 20:49:41 +00:00
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:
@@ -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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user