This commit is contained in:
Julien Fastré 2024-06-11 16:58:33 +02:00
parent 9ec4c77fb7
commit 0bfb3de465
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
5 changed files with 9 additions and 11 deletions

View File

@ -18,8 +18,6 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Templating\Entity\UserRender; use Chill\MainBundle\Templating\Entity\UserRender;
use DateTime;
use DateTimeImmutable;
use libphonenumber\PhoneNumber; use libphonenumber\PhoneNumber;
use Symfony\Component\Clock\ClockInterface; use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
@ -48,11 +46,13 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
} }
/** /**
* @param mixed|null $format
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/ */
public function normalize($object, $format = null, array $context = []) public function normalize($object, $format = null, array $context = [])
{ {
/** @var array{"chill:user:at_date"?: DateTimeImmutable|DateTime} $context */ /** @var array{"chill:user:at_date"?: \DateTimeImmutable|\DateTime} $context */
/** @var User $object */ /** @var User $object */
$userJobContext = array_merge( $userJobContext = array_merge(
$context, $context,
@ -84,8 +84,8 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
} }
$at = $context[self::AT_DATE] ?? $this->clock->now(); $at = $context[self::AT_DATE] ?? $this->clock->now();
if ($at instanceof DateTime) { if ($at instanceof \DateTime) {
$at = DateTimeImmutable::createFromMutable($at); $at = \DateTimeImmutable::createFromMutable($at);
} }
$data = [ $data = [

View File

@ -53,7 +53,7 @@ class UserRender implements ChillEntityRenderInterface
if (null === $opts['at_date']) { if (null === $opts['at_date']) {
$opts['at_date'] = $this->clock->now(); $opts['at_date'] = $this->clock->now();
} elseif ($opts['at_date'] instanceof \DateTime) { } elseif ($opts['at_date'] instanceof \DateTime) {
$opts['at_date'] = DateTimeImmutable::createFromMutable($opts['at_date']); $opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']);
} }
return $this->engine->render('@ChillMain/Entity/user.html.twig', [ return $this->engine->render('@ChillMain/Entity/user.html.twig', [
@ -71,7 +71,7 @@ class UserRender implements ChillEntityRenderInterface
if (null === $opts['at_date']) { if (null === $opts['at_date']) {
$opts['at_date'] = $this->clock->now(); $opts['at_date'] = $this->clock->now();
} elseif ($opts['at_date'] instanceof \DateTime) { } elseif ($opts['at_date'] instanceof \DateTime) {
$opts['at_date'] = DateTimeImmutable::createFromMutable($opts['at_date']); $opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']);
} }
$str = $entity->getLabel(); $str = $entity->getLabel();

View File

@ -1514,7 +1514,7 @@ class AccompanyingPeriod implements
public function getCurrentUserHistory(): ?UserHistory public function getCurrentUserHistory(): ?UserHistory
{ {
return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => $userHistory->getEndDate() === null); return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => null === $userHistory->getEndDate());
} }
private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self

View File

@ -18,9 +18,7 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer; use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\AccompanyingPeriod\Events\UserRefEventSubscriber;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;