Implement global circular reference handler in line with latest symfony practices and remove now redundant code from current normalizers

This commit is contained in:
2025-10-01 14:55:24 +02:00
parent d4379cef6a
commit f17ed7a4f8
6 changed files with 68 additions and 55 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace Chill\MainBundle\Serializer;
class CircularReferenceHandler
{
public function handle(object $object, ?string $format = null, array $context = []): mixed
{
if (method_exists($object, 'getId')) {
return [
'id' => $object->getId(),
'_class' => (new \ReflectionClass($object))->getShortName(),
];
}
return spl_object_id($object);
}
}