mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-09 05:38:25 +00:00
Implement global circular reference handler in line with latest symfony practices and remove now redundant code from current normalizers
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user