CodeExplorer AnnotationLoader example
$context->
addExtension('foo',
new ArrayEntity());
static::
assertNotNull($context->
getExtension('foo'
));
$versionContext =
$context->
createWithVersionId(Uuid::
randomHex());
static::
assertNotNull($versionContext->
getExtension('foo'
));
} public function testExtensionsAreStripped(): void
{ $classMetadataFactory =
new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$discriminator =
new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
$normalizers =
[new StructNormalizer(),
new ObjectNormalizer($classMetadataFactory, null, null, null,
$discriminator),
new ArrayDenormalizer()];
$serializer =
new Serializer($normalizers,
[new JsonEncoder()]);
$context = Context::
createDefaultContext();
$context->
addExtension('foo',
new ArrayEntity());
$serialized =
$serializer->
serialize($context, 'json'
);
$deserialized =
$serializer->
deserialize($serialized, Context::
class, 'json'
);