mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 14:54:57 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -19,12 +19,6 @@ use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use RuntimeException;
|
||||
|
||||
use function explode;
|
||||
use function implode;
|
||||
use function strtr;
|
||||
use function trim;
|
||||
|
||||
final class AddressReferenceRepository implements ObjectRepository
|
||||
{
|
||||
@@ -77,7 +71,7 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
*
|
||||
* @return AddressReference[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -94,11 +88,11 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
$rsm->addRootEntityFromClassMetadata(AddressReference::class, 'cma');
|
||||
$query->addSelectClause($rsm->generateSelectClause());
|
||||
} else {
|
||||
throw new RuntimeException('not implemented');
|
||||
throw new \RuntimeException('not implemented');
|
||||
}
|
||||
|
||||
$sql = strtr(
|
||||
$query->buildQuery() . 'ORDER BY pertinence DESC, lpad(streetnumber, 10, \'0\') ASC OFFSET ? LIMIT ? ',
|
||||
$sql = \strtr(
|
||||
$query->buildQuery().'ORDER BY pertinence DESC, lpad(streetnumber, 10, \'0\') ASC OFFSET ? LIMIT ? ',
|
||||
// little hack for adding sql method to point
|
||||
['cma.point AS point' => 'ST_AsGeojson(cma.point) AS point']
|
||||
);
|
||||
@@ -109,7 +103,7 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?AddressReference
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?AddressReference
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
@@ -121,10 +115,10 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
|
||||
private function buildQueryByPostalCodePattern(PostalCode $postalCode, string $pattern): SearchApiQuery
|
||||
{
|
||||
$pattern = trim($pattern);
|
||||
$pattern = \trim($pattern);
|
||||
|
||||
if ('' === $pattern) {
|
||||
throw new RuntimeException('the search pattern must not be empty');
|
||||
throw new \RuntimeException('the search pattern must not be empty');
|
||||
}
|
||||
$query = new SearchApiQuery();
|
||||
|
||||
@@ -138,8 +132,8 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
$andWhere = [];
|
||||
$andWhereArgs = [];
|
||||
|
||||
foreach (explode(' ', $pattern) as $part) {
|
||||
$part = trim($part);
|
||||
foreach (\explode(' ', $pattern) as $part) {
|
||||
$part = \trim($part);
|
||||
|
||||
if ('' === $part) {
|
||||
continue;
|
||||
@@ -154,8 +148,8 @@ final class AddressReferenceRepository implements ObjectRepository
|
||||
array_push($pertinenceArgs, $part, $part);
|
||||
}
|
||||
$query
|
||||
->setSelectPertinence(implode(' + ', $pertinenceClause), $pertinenceArgs)
|
||||
->andWhereClause(implode(' AND ', $andWhere), $andWhereArgs);
|
||||
->setSelectPertinence(\implode(' + ', $pertinenceClause), $pertinenceArgs)
|
||||
->andWhereClause(\implode(' AND ', $andWhere), $andWhereArgs);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ final class AddressRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(Address::class);
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -50,12 +50,12 @@ final class AddressRepository implements ObjectRepository
|
||||
*
|
||||
* @return Address[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Address
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Address
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -51,12 +51,12 @@ final class CenterRepository implements CenterRepositoryInterface
|
||||
*
|
||||
* @return Center[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Center
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Center
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class CivilityRepository implements CivilityRepositoryInterface
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ interface CivilityRepositoryInterface extends ObjectRepository
|
||||
/**
|
||||
* @return array|Civility[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array;
|
||||
|
||||
public function findOneBy(array $criteria): ?Civility;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ final class CountryRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(Country::class);
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -50,12 +50,12 @@ final class CountryRepository implements ObjectRepository
|
||||
*
|
||||
* @return Country[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Country
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Country
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class CronJobExecutionRepository implements CronJobExecutionRepositoryInterface
|
||||
/**
|
||||
* @return array|CronJobExecution[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ interface CronJobExecutionRepositoryInterface extends ObjectRepository
|
||||
/**
|
||||
* @return array|CronJobExecution[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array;
|
||||
|
||||
public function findOneBy(array $criteria): ?CronJobExecution;
|
||||
|
||||
|
@@ -49,7 +49,7 @@ final class GeographicalUnitLayerLayerRepository implements GeographicalUnitLaye
|
||||
/**
|
||||
* @return array|GeographicalUnitLayer[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ final class GeographicalUnitRepository implements GeographicalUnitRepositoryInte
|
||||
$this->repository = $em->getRepository($this->getClassName());
|
||||
}
|
||||
|
||||
|
||||
public function countGeographicalUnitContainingAddress(Address $address): int
|
||||
{
|
||||
$qb = $this->buildQueryGeographicalUnitContainingAddress($address);
|
||||
@@ -45,7 +44,7 @@ final class GeographicalUnitRepository implements GeographicalUnitRepositoryInte
|
||||
return $qb
|
||||
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
|
||||
->addOrderBy('IDENTITY(gu.layer)')
|
||||
->addOrderBy(('gu.unitName'))
|
||||
->addOrderBy('gu.unitName')
|
||||
->getQuery()
|
||||
->setFirstResult($offset)
|
||||
->setMaxResults($limit)
|
||||
@@ -57,6 +56,7 @@ final class GeographicalUnitRepository implements GeographicalUnitRepositoryInte
|
||||
$qb = $this->repository
|
||||
->createQueryBuilder('gu')
|
||||
;
|
||||
|
||||
return $qb
|
||||
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
|
||||
->innerJoin(Address::class, 'address', Join::WITH, 'ST_CONTAINS(gu.geom, address.point) = TRUE')
|
||||
@@ -81,12 +81,12 @@ final class GeographicalUnitRepository implements GeographicalUnitRepositoryInte
|
||||
->createQueryBuilder('gu')
|
||||
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
|
||||
->addOrderBy('IDENTITY(gu.layer)')
|
||||
->addOrderBy(('gu.unitName'))
|
||||
->addOrderBy('gu.unitName')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): ?GeographicalUnit
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): ?GeographicalUnit
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -18,13 +18,10 @@ use Doctrine\Persistence\ObjectRepository;
|
||||
interface GeographicalUnitRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* Return the geographical units as @link{SimpleGeographicalUnitDTO} whithin the address is contained.
|
||||
* Return the geographical units as @see{SimpleGeographicalUnitDTO} whithin the address is contained.
|
||||
*
|
||||
* This query is executed in real time (without the refresh of the materialized view which load the addresses).
|
||||
*
|
||||
* @param Address $address
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @return SimpleGeographicalUnitDTO[]
|
||||
*/
|
||||
public function findGeographicalUnitContainingAddress(Address $address, int $offset = 0, int $limit = 50): array;
|
||||
|
@@ -44,12 +44,12 @@ final class GroupCenterRepository implements ObjectRepository
|
||||
*
|
||||
* @return GroupCenter[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?GroupCenter
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?GroupCenter
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -43,12 +43,12 @@ final class LanguageRepository implements LanguageRepositoryInterface
|
||||
*
|
||||
* @return Language[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Language
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Language
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -29,9 +29,9 @@ interface LanguageRepositoryInterface extends ObjectRepository
|
||||
*
|
||||
* @return Language[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array;
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Language;
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Language;
|
||||
|
||||
public function getClassName(): string;
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ final class NotificationRepository implements ObjectRepository
|
||||
FROM chill_main_notification cmn
|
||||
SQL;
|
||||
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $em)
|
||||
{
|
||||
$this->repository = $em->getRepository(Notification::class);
|
||||
@@ -59,6 +58,7 @@ final class NotificationRepository implements ObjectRepository
|
||||
|
||||
/**
|
||||
* @param list<array{relatedEntityClass: class-string, relatedEntityId: int}> $more
|
||||
*
|
||||
* @return array{unread: int, sent: int, total: int}
|
||||
*/
|
||||
public function countNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user, array $more = []): array
|
||||
@@ -67,7 +67,7 @@ final class NotificationRepository implements ObjectRepository
|
||||
|
||||
if ([] === $more) {
|
||||
if (null === $this->notificationByRelatedEntityAndUserAssociatedStatement) {
|
||||
$sql = self::BASE_COUNTER_SQL . ' WHERE relatedentityclass = :relatedEntityClass AND relatedentityid = :relatedEntityId AND sender_id IS NOT NULL';
|
||||
$sql = self::BASE_COUNTER_SQL.' WHERE relatedentityclass = :relatedEntityClass AND relatedentityid = :relatedEntityId AND sender_id IS NOT NULL';
|
||||
|
||||
$this->notificationByRelatedEntityAndUserAssociatedStatement =
|
||||
$this->em->getConnection()->prepare($sql);
|
||||
@@ -83,14 +83,14 @@ final class NotificationRepository implements ObjectRepository
|
||||
$wheres = [];
|
||||
foreach ([
|
||||
['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId],
|
||||
...$more
|
||||
...$more,
|
||||
] as $k => ['relatedEntityClass' => $relClass, 'relatedEntityId' => $relId]) {
|
||||
$wheres[] = "(relatedEntityClass = :relatedEntityClass_{$k} AND relatedEntityId = :relatedEntityId_{$k})";
|
||||
$sqlParams["relatedEntityClass_{$k}"] = $relClass;
|
||||
$sqlParams["relatedEntityId_{$k}"] = $relId;
|
||||
}
|
||||
|
||||
$sql = self::BASE_COUNTER_SQL . ' WHERE sender_id IS NOT NULL AND (' . implode(' OR ', $wheres) . ')';
|
||||
$sql = self::BASE_COUNTER_SQL.' WHERE sender_id IS NOT NULL AND ('.implode(' OR ', $wheres).')';
|
||||
|
||||
$result = $this->em->getConnection()->fetchAssociative($sql, $sqlParams);
|
||||
}
|
||||
@@ -194,13 +194,14 @@ final class NotificationRepository implements ObjectRepository
|
||||
*
|
||||
* @return Notification[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{relatedEntityClass: class-string, relatedEntityId: int}> $more
|
||||
*
|
||||
* @return array|Notification[]
|
||||
*/
|
||||
public function findNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user, array $more): array
|
||||
@@ -213,7 +214,7 @@ final class NotificationRepository implements ObjectRepository
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Notification
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Notification
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
@@ -226,11 +227,11 @@ final class NotificationRepository implements ObjectRepository
|
||||
$rsm = new Query\ResultSetMappingBuilder($this->em);
|
||||
$rsm->addRootEntityFromClassMetadata(Notification::class, 'cmn');
|
||||
|
||||
$sql = 'SELECT ' . $rsm->generateSelectClause(['cmn' => 'cmn']) . ' ' .
|
||||
'FROM chill_main_notification cmn ' .
|
||||
'WHERE ' .
|
||||
'EXISTS (select 1 FROM chill_main_notification_addresses_unread cmnau WHERE cmnau.user_id = :userId and cmnau.notification_id = cmn.id) ' .
|
||||
'ORDER BY cmn.date DESC ' .
|
||||
$sql = 'SELECT '.$rsm->generateSelectClause(['cmn' => 'cmn']).' '.
|
||||
'FROM chill_main_notification cmn '.
|
||||
'WHERE '.
|
||||
'EXISTS (select 1 FROM chill_main_notification_addresses_unread cmnau WHERE cmnau.user_id = :userId and cmnau.notification_id = cmn.id) '.
|
||||
'ORDER BY cmn.date DESC '.
|
||||
'LIMIT :limit OFFSET :offset';
|
||||
|
||||
$nq = $this->em->createNativeQuery($sql, $rsm)
|
||||
|
@@ -57,12 +57,12 @@ final class PermissionsGroupRepository implements ObjectRepository
|
||||
*
|
||||
* @return PermissionsGroup[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?PermissionsGroup
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?PermissionsGroup
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use RuntimeException;
|
||||
|
||||
final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
{
|
||||
@@ -55,7 +54,7 @@ final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -69,7 +68,7 @@ final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
$query->addSelectClause($rsm->generateSelectClause());
|
||||
|
||||
$sql = strtr(
|
||||
$query->buildQuery() . 'ORDER BY pertinence DESC, canonical ASC OFFSET ? LIMIT ? ',
|
||||
$query->buildQuery().'ORDER BY pertinence DESC, canonical ASC OFFSET ? LIMIT ? ',
|
||||
// little hack for adding sql method to point
|
||||
['cmpc.center AS center' => 'ST_AsGeojson(cmpc.center) AS center']
|
||||
);
|
||||
@@ -80,7 +79,7 @@ final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?PostalCode
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?PostalCode
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
@@ -95,7 +94,7 @@ final class PostalCodeRepository implements PostalCodeRepositoryInterface
|
||||
$pattern = trim($pattern);
|
||||
|
||||
if ('' === $pattern) {
|
||||
throw new RuntimeException('the search pattern must not be empty');
|
||||
throw new \RuntimeException('the search pattern must not be empty');
|
||||
}
|
||||
$query = new SearchApiQuery();
|
||||
|
||||
|
@@ -32,11 +32,11 @@ interface PostalCodeRepositoryInterface extends ObjectRepository
|
||||
*
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array;
|
||||
|
||||
public function findByPattern(string $pattern, ?Country $country, ?int $start = 0, ?int $limit = 50): array;
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?PostalCode;
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?PostalCode;
|
||||
|
||||
public function getClassName(): string;
|
||||
}
|
||||
|
@@ -51,12 +51,12 @@ final class RegroupmentRepository implements ObjectRepository
|
||||
*
|
||||
* @return Regroupment[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Regroupment
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Regroupment
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -44,12 +44,12 @@ final class RoleScopeRepository implements ObjectRepository
|
||||
*
|
||||
* @return RoleScope[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?RoleScope
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?RoleScope
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -42,12 +42,12 @@ class SavedExportRepository implements SavedExportRepositoryInterface
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
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 findByUser(User $user, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array
|
||||
public function findByUser(User $user, ?array $orderBy = [], int $limit = null, int $offset = null): array
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('se');
|
||||
|
||||
@@ -64,7 +64,7 @@ class SavedExportRepository implements SavedExportRepositoryInterface
|
||||
}
|
||||
|
||||
foreach ($orderBy as $field => $order) {
|
||||
$qb->addOrderBy('se.' . $field, $order);
|
||||
$qb->addOrderBy('se.'.$field, $order);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
|
@@ -27,12 +27,12 @@ interface SavedExportRepositoryInterface extends ObjectRepository
|
||||
*/
|
||||
public function findAll(): array;
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array;
|
||||
|
||||
/**
|
||||
* @return array|SavedExport[]
|
||||
*/
|
||||
public function findByUser(User $user, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array;
|
||||
public function findByUser(User $user, ?array $orderBy = [], int $limit = null, int $offset = null): array;
|
||||
|
||||
public function findOneBy(array $criteria): ?SavedExport;
|
||||
|
||||
|
@@ -58,12 +58,12 @@ final class ScopeRepository implements ScopeRepositoryInterface
|
||||
*
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Scope
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Scope
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
@@ -32,14 +32,14 @@ interface ScopeRepositoryInterface extends ObjectRepository
|
||||
public function findAllActive(): array;
|
||||
|
||||
/**
|
||||
* @param null|mixed $limit
|
||||
* @param null|mixed $offset
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array;
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array;
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?Scope;
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Scope;
|
||||
|
||||
public function getClassName(): string;
|
||||
}
|
||||
|
@@ -13,8 +13,6 @@ namespace Chill\MainBundle\Repository\User;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
|
@@ -13,8 +13,6 @@ namespace Chill\MainBundle\Repository\User;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
|
@@ -21,8 +21,8 @@ interface UserACLAwareRepositoryInterface
|
||||
* Find the users reaching the given center and scope, for the given role.
|
||||
*
|
||||
* @param array|Center|Center[]|null $center
|
||||
* @param array|Scope|Scope[]|null $scope
|
||||
* @param bool $onlyActive true if get only active users
|
||||
* @param array|Scope|Scope[]|null $scope
|
||||
* @param bool $onlyActive true if get only active users
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
|
@@ -48,7 +48,7 @@ class UserJobRepository implements UserJobRepositoryInterface
|
||||
*
|
||||
* @return array|object[]|UserJob[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ interface UserJobRepositoryInterface extends ObjectRepository
|
||||
*
|
||||
* @return array|object[]|UserJob[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null);
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
|
||||
|
||||
public function findOneBy(array $criteria): ?UserJob;
|
||||
|
||||
|
@@ -22,8 +22,6 @@ use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
use function count;
|
||||
|
||||
final readonly class UserRepository implements UserRepositoryInterface
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
@@ -127,7 +125,7 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
|
||||
$converted['absenceStart'] = null !== $u['absencestart'] ? new \DateTimeImmutable($u['absencestart']) : null;
|
||||
|
||||
/** @phpstan-ignore-next-line phpstan does not take into account that all required keys will be present */
|
||||
/* @phpstan-ignore-next-line phpstan does not take into account that all required keys will be present */
|
||||
yield $converted;
|
||||
}
|
||||
}
|
||||
@@ -160,14 +158,13 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -175,7 +172,7 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
/**
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findByActive(?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findByActive(array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->findBy(['enabled' => true], $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -185,12 +182,12 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
*
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findByNotHavingAttribute(string $key, ?int $limit = null, ?int $offset = null): array
|
||||
public function findByNotHavingAttribute(string $key, int $limit = null, int $offset = null): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->entityManager);
|
||||
$rsm->addRootEntityFromClassMetadata(User::class, 'u');
|
||||
|
||||
$sql = 'SELECT ' . $rsm->generateSelectClause() . ' FROM users u WHERE NOT attributes ?? :key OR attributes IS NULL AND enabled IS TRUE';
|
||||
$sql = 'SELECT '.$rsm->generateSelectClause().' FROM users u WHERE NOT attributes ?? :key OR attributes IS NULL AND enabled IS TRUE';
|
||||
|
||||
if (null !== $limit) {
|
||||
$sql .= " LIMIT {$limit}";
|
||||
@@ -203,7 +200,7 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
return $this->entityManager->createNativeQuery($sql, $rsm)->setParameter(':key', $key)->getResult();
|
||||
}
|
||||
|
||||
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array
|
||||
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], int $limit = null, int $offset = null): array
|
||||
{
|
||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
||||
|
||||
@@ -218,13 +215,13 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
}
|
||||
|
||||
foreach ($orderBy as $field => $order) {
|
||||
$qb->addOrderBy('u.' . $field, $order);
|
||||
$qb->addOrderBy('u.'.$field, $order);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?User
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?User
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
@@ -248,17 +245,16 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
* and, then filter those users having some flags.
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\User[] $amongstUsers
|
||||
* @param mixed $flag
|
||||
*/
|
||||
public function findUsersHavingFlags($flag, array $amongstUsers = []): array
|
||||
{
|
||||
$gcs = $this
|
||||
->entityManager
|
||||
->createQuery(
|
||||
'SELECT DISTINCT gc ' .
|
||||
'FROM ' . GroupCenter::class . ' gc ' .
|
||||
'JOIN gc.permissionsGroup pg ' .
|
||||
'WHERE ' .
|
||||
'SELECT DISTINCT gc '.
|
||||
'FROM '.GroupCenter::class.' gc '.
|
||||
'JOIN gc.permissionsGroup pg '.
|
||||
'WHERE '.
|
||||
'JSONB_EXISTS_IN_ARRAY(pg.flags, :flag) = :true '
|
||||
)
|
||||
->setParameters([
|
||||
@@ -267,7 +263,7 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
])
|
||||
->getResult();
|
||||
|
||||
if (count($gcs) === 0) {
|
||||
if (0 === \count($gcs)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -280,8 +276,8 @@ final readonly class UserRepository implements UserRepositoryInterface
|
||||
$orx = $qb->expr()->orX();
|
||||
|
||||
foreach ($gcs as $i => $gc) {
|
||||
$orx->add(':gc_' . $i . ' MEMBER OF u.groupCenters');
|
||||
$qb->setParameter('gc_' . $i, $gc);
|
||||
$orx->add(':gc_'.$i.' MEMBER OF u.groupCenters');
|
||||
$qb->setParameter('gc_'.$i, $gc);
|
||||
}
|
||||
|
||||
$qb->andWhere($orx);
|
||||
|
@@ -33,6 +33,7 @@ interface UserRepositoryInterface extends ObjectRepository
|
||||
* The main purpose for this method is to provide a lightweight list of all users in the database.
|
||||
*
|
||||
* @param string $lang The lang to display all the translatable string (no fallback if not present)
|
||||
*
|
||||
* @return iterable<array{id: int, username: string, email: string, enabled: bool, civility_id: int, civility_abbreviation: string, civility_name: string, label: string, mainCenter_id: int, mainCenter_name: string, mainScope_id: int, mainScope_name: string, userJob_id: int, userJob_name: string, currentLocation_id: int, currentLocation_name: string, mainLocation_id: int, mainLocation_name: string, absenceStart: \DateTimeImmutable}>
|
||||
*/
|
||||
public function findAllAsArray(string $lang): iterable;
|
||||
@@ -50,16 +51,16 @@ interface UserRepositoryInterface extends ObjectRepository
|
||||
/**
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findByActive(?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findByActive(array $orderBy = null, int $limit = null, int $offset = null): array;
|
||||
|
||||
/**
|
||||
* Find users which does not have a key on attribute column.
|
||||
*
|
||||
* @return array|User[]
|
||||
*/
|
||||
public function findByNotHavingAttribute(string $key, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findByNotHavingAttribute(string $key, int $limit = null, int $offset = null): array;
|
||||
|
||||
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], ?int $limit = null, ?int $offset = null): array;
|
||||
public function findByUsernameOrEmail(string $pattern, ?array $orderBy = [], int $limit = null, int $offset = null): array;
|
||||
|
||||
public function findOneByUsernameOrEmail(string $pattern): ?User;
|
||||
|
||||
@@ -71,7 +72,6 @@ interface UserRepositoryInterface extends ObjectRepository
|
||||
* and, then filter those users having some flags.
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\User[] $amongstUsers
|
||||
* @param mixed $flag
|
||||
*/
|
||||
public function findUsersHavingFlags(mixed $flag, array $amongstUsers = []): array;
|
||||
}
|
||||
|
@@ -72,13 +72,13 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
foreach ($relateds as $related) {
|
||||
$orX->add(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq('w.relatedEntityClass', ':entity_class_' . $i),
|
||||
$qb->expr()->eq('w.relatedEntityId', ':entity_id_' . $i)
|
||||
$qb->expr()->eq('w.relatedEntityClass', ':entity_class_'.$i),
|
||||
$qb->expr()->eq('w.relatedEntityId', ':entity_id_'.$i)
|
||||
)
|
||||
);
|
||||
$qb
|
||||
->setParameter('entity_class_' . $i, $related['entityClass'])
|
||||
->setParameter('entity_id_' . $i, $related['entityId']);
|
||||
->setParameter('entity_class_'.$i, $related['entityClass'])
|
||||
->setParameter('entity_id_'.$i, $related['entityId']);
|
||||
++$i;
|
||||
}
|
||||
$qb->where($orX);
|
||||
@@ -100,22 +100,22 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|mixed $limit
|
||||
* @param null|mixed $offset
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return array|EntityWorkflow[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findByCc(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findByCc(User $user, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByCc($user)->select('ew');
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.' . $key, $sort);
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
}
|
||||
|
||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||
@@ -123,12 +123,12 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByDest(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findByDest(User $user, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByDest($user)->select('ew');
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.' . $key, $sort);
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
}
|
||||
|
||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||
@@ -136,12 +136,12 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByPreviousDestWithoutReaction(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findByPreviousDestWithoutReaction(User $user, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByPreviousDestWithoutReaction($user)->select('ew');
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.' . $key, $sort);
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
}
|
||||
|
||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||
@@ -149,12 +149,12 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByPreviousTransitionned(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findByPreviousTransitionned(User $user, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByPreviousTransitionned($user)->select('ew')->distinct(true);
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.' . $key, $sort);
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
}
|
||||
|
||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||
@@ -162,12 +162,12 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findBySubscriber(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBySubscriber(User $user, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryBySubscriber($user)->select('ew');
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.' . $key, $sort);
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
}
|
||||
|
||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||
|
@@ -27,7 +27,7 @@ class EntityWorkflowStepRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(EntityWorkflowStep::class);
|
||||
}
|
||||
|
||||
public function countUnreadByUser(User $user, ?array $orderBy = null, $limit = null, $offset = null): int
|
||||
public function countUnreadByUser(User $user, array $orderBy = null, $limit = null, $offset = null): int
|
||||
{
|
||||
$qb = $this->buildQueryByUser($user)->select('count(e)');
|
||||
|
||||
@@ -44,7 +44,7 @@ class EntityWorkflowStepRepository implements ObjectRepository
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
Reference in New Issue
Block a user