-
Serializer component question. I have an array like this: $data = [
'caching' => [
'cacheConfigurations' => [
'hash' => [
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend',
],
'imagesizes' => [
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend',
'options' => [
'compression' => true,
],
],
],
],
]; And I'm trying to denormalize it into an object structure like this: class System
{
public function __construct(
/** @var CacheConfig[] */
public array $cacheConfigurations = [],
}
class CacheConfig
{
public function __construct(
public string $backend = '',
#[SerializedName('options')]
public ?CacheOptions $options = null,
) {}
} Serializer definition: protected function getSerializer(): Serializer
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory);
$infoExtractor = new ReflectionExtractor();
$normalizer = new ObjectNormalizer(
classMetadataFactory: $classMetadataFactory,
nameConverter: $metadataAwareNameConverter,
propertyTypeExtractor: $infoExtractor,
);
return new Serializer([new DateTimeNormalizer(), new PropertyNormalizer(), new ArrayDenormalizer(), $normalizer]);
} Problem: The |
Beta Was this translation helpful? Give feedback.
Answered by
lyrixx
Aug 10, 2021
Replies: 1 comment 9 replies
-
I guess you missed the PHPdoc extractor |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
lyrixx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess you missed the PHPdoc extractor