protected function fixTimeZoneOnNormalization($object, $normalized, \DateTimeZone $orgTimezone): void
    {
        // Change timezone of all normalized dates to organization's current
        // timezone if it is different than the default PHP timezone.
        if (date_default_timezone_get() !== $orgTimezone->getName()) {
            $ro = new \ReflectionObject($object);
            // @psalm-suppress required since symfony/serializer >= 4.2.0
            // @see https://github.com/symfony/symfony/pull/28709
            /** @psalm-suppress InvalidArgument */
            $dateDenormalizer = new DateTimeNormalizer(EntityInterface::DATE_FORMAT, $orgTimezone);
            foreach ($ro->getProperties() as $property) {
                $property->setAccessible(true);
                $value = $property->getValue($object);
                if ($value instanceof \DateTimeImmutable) {
                    $normalized->{$property->getName()} = $dateDenormalizer->normalize($value, \DateTimeImmutable::class);
                }
            }
        }
    }
protected function fixTimeZoneOnNormalization($object, $normalized, \DateTimeZone $orgTimezone): void
    {
        // Change timezone of all normalized dates to organization's current
        // timezone if it is different than the default PHP timezone.
        if (date_default_timezone_get() !== $orgTimezone->getName()) {
            $ro = new \ReflectionObject($object);
            // @psalm-suppress required since symfony/serializer >= 4.2.0
            // @see https://github.com/symfony/symfony/pull/28709
            /** @psalm-suppress InvalidArgument */
            $dateDenormalizer = new DateTimeNormalizer(EntityInterface::DATE_FORMAT, $orgTimezone);
            foreach ($ro->getProperties() as $property) {
                $property->setAccessible(true);
                $value = $property->getValue($object);
                if ($value instanceof \DateTimeImmutable) {
                    $normalized->{$property->getName()} = $dateDenormalizer->normalize($value, \DateTimeImmutable::class);
                }
            }
        }
    }
protected function fixTimeZoneOnNormalization ( $ object , $ normalized , \ DateTimeZone $ orgTimezone ) : void { // Change timezone of all normalized dates to organization's current // timezone if it is different than the default PHP timezone. if ( date_default_timezone_get ( ) !== $ orgTimezone -> getName ( ) ) { $ ro = new \ ReflectionObject ( $ object ) ; // @psalm-suppress required since symfony/serializer >= 4.2.0 // @see https://github.com/symfony/symfony/pull/28709 /** @psalm-suppress InvalidArgument */ $ dateDenormalizer = new DateTimeNormalizer ( EntityInterface :: DATE_FORMAT , $ orgTimezone ) ; foreach ( $ ro -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ value = $ property -> getValue ( $ object ) ; if ( $ value instanceof \ DateTimeImmutable ) { $ normalized -> { $ property -> getName ( ) } = $ dateDenormalizer -> normalize ( $ value , \ DateTimeImmutable :: class ) ; } } } }
Fixes the timezone of all DateTimeImmutable objects before the entity
is being sent to Apigee Edge.

It process object properties non-recursively because it gets called
on nested object automatically.

@param object $object
The object that has been normalized.
@param $normalized
The normalized object.
@param \DateTimeZone $orgTimezone
Timezone of the organization retrieved from the organization profile.
Fixes the timezone of all DateTimeImmutable objects before the entity is being sent to Apigee Edge .