getObject(); if ($object instanceof PersistentCollection) { $event->setType('ArrayCollection'); return; } if ( ! $object instanceof Proxy && ! $object instanceof ORMProxy) { return; } $object->__load(); $event->setType(get_parent_class($object)); } public static function getSubscribedEvents() { return array( array('event' => 'serializer.pre_serialize', 'method' => 'onPreSerialize'), ); } }