mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Repository;
|
|
|
|
use Chill\MainBundle\Entity\GeographicalUnit;
|
|
use Chill\MainBundle\Entity\GeographicalUnitDTO;
|
|
use Chill\MainBundle\Entity\GeographicalUnitLayer;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface
|
|
{
|
|
private EntityRepository $repository;
|
|
|
|
private EntityManagerInterface $em;
|
|
|
|
public function __construct(EntityManagerInterface $em)
|
|
{
|
|
$this->repository = $em->getRepository($this->getClassName());
|
|
$this->em = $em;
|
|
}
|
|
|
|
|
|
public function find($id): ?GeographicalUnit
|
|
{
|
|
return $this->repository->find($id);
|
|
}
|
|
|
|
/**
|
|
* Will return only partial object, where the @link{GeographicalUnit::geom} property is not loaded
|
|
*
|
|
* @return array|GeographicalUnit[]
|
|
*/
|
|
public function findAll(): array
|
|
{
|
|
return $this->repository
|
|
->createQueryBuilder('gu')
|
|
->select('PARTIAL gu.{id,unitName,unitRefId,layer}')
|
|
->addOrderBy('IDENTITY(gu.layer)')
|
|
->addOrderBy(('gu.unitName'))
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): ?GeographicalUnit
|
|
{
|
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
|
}
|
|
|
|
public function findOneBy(array $criteria): ?GeographicalUnit
|
|
{
|
|
return $this->repository->findOneBy($criteria);
|
|
}
|
|
|
|
public function getClassName(): string
|
|
{
|
|
return GeographicalUnit::class;
|
|
}
|
|
} |