|
@@ -153,6 +153,15 @@ final class GraphNavigator
|
|
$this->context->startVisiting($data);
|
|
$this->context->startVisiting($data);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Trigger pre-serialization callbacks, and listeners if they exist.
|
|
|
|
+ // Dispatch pre-serialization event before handling data to have ability change type in listener
|
|
|
|
+ if ($isSerializing) {
|
|
|
|
+ if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.pre_serialize', $type['name'], $this->context->getFormat())) {
|
|
|
|
+ $this->dispatcher->dispatch('serializer.pre_serialize', $type['name'], $this->context->getFormat(), $event = new PreSerializeEvent($visitor, $data, $type));
|
|
|
|
+ $type = $event->getType();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// First, try whether a custom handler exists for the given type. This is done
|
|
// First, try whether a custom handler exists for the given type. This is done
|
|
// before loading metadata because the type name might not be a class, but
|
|
// before loading metadata because the type name might not be a class, but
|
|
// could also simply be an artifical type.
|
|
// could also simply be an artifical type.
|
|
@@ -164,14 +173,6 @@ final class GraphNavigator
|
|
return $rs;
|
|
return $rs;
|
|
}
|
|
}
|
|
|
|
|
|
- // Trigger pre-serialization callbacks, and listeners if they exist.
|
|
|
|
- if ($isSerializing) {
|
|
|
|
- if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.pre_serialize', $type['name'], $this->context->getFormat())) {
|
|
|
|
- $this->dispatcher->dispatch('serializer.pre_serialize', $type['name'], $this->context->getFormat(), $event = new PreSerializeEvent($visitor, $data, $type));
|
|
|
|
- $type = $event->getType();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Load metadata, and check whether this class should be excluded.
|
|
// Load metadata, and check whether this class should be excluded.
|
|
$metadata = $this->metadataFactory->getMetadataForClass($type['name']);
|
|
$metadata = $this->metadataFactory->getMetadataForClass($type['name']);
|
|
if (null !== $this->exclusionStrategy && $this->exclusionStrategy->shouldSkipClass($metadata, $this->context)) {
|
|
if (null !== $this->exclusionStrategy && $this->exclusionStrategy->shouldSkipClass($metadata, $this->context)) {
|