mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
fix cs
This commit is contained in:
@@ -18,8 +18,8 @@ use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\Context;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ResidentialAddressRepository::class)
|
||||
@@ -49,7 +49,7 @@ class ResidentialAddress
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read"})
|
||||
* @Context(normalizationContext={"groups"={"minimal"}})
|
||||
* @Context(normalizationContext={"groups": {"minimal"}})
|
||||
*/
|
||||
private ?Person $hostPerson = null;
|
||||
|
||||
|
@@ -32,26 +32,11 @@ class ResidentialAddressRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, ResidentialAddress::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @param DateTimeImmutable|null $at
|
||||
* @return array|ResidentialAddress[]|null
|
||||
*/
|
||||
public function findCurrentResidentialAddressByPerson(Person $person, ?DateTimeImmutable $at = null): array
|
||||
{
|
||||
return $this->buildQueryFindCurrentResidentialAddresses($person, $at)
|
||||
->select('ra')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder
|
||||
{
|
||||
$date = null === $at ? new DateTimeImmutable('today') : $at;
|
||||
$qb = $this->createQueryBuilder('ra');
|
||||
|
||||
|
||||
|
||||
$dateFilter = $qb->expr()->andX(
|
||||
$qb->expr()->lte('ra.startDate', ':dateIn'),
|
||||
$qb->expr()->orX(
|
||||
@@ -69,6 +54,17 @@ class ResidentialAddressRepository extends ServiceEntityRepository
|
||||
return $qb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ResidentialAddress[]|null
|
||||
*/
|
||||
public function findCurrentResidentialAddressByPerson(Person $person, ?DateTimeImmutable $at = null): array
|
||||
{
|
||||
return $this->buildQueryFindCurrentResidentialAddresses($person, $at)
|
||||
->select('ra')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return ResidentialAddress[] Returns an array of ResidentialAddress objects
|
||||
// */
|
||||
|
@@ -31,6 +31,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Serialize a Person entity.
|
||||
@@ -207,8 +209,8 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'gender' => $person->getGender(),
|
||||
];
|
||||
|
||||
if (in_array("minimal", $groups) && 1 === count($groups)) {
|
||||
return $data;
|
||||
if (in_array('minimal', $groups, true) && 1 === count($groups)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return array_merge($data, [
|
||||
|
Reference in New Issue
Block a user