getFieldSerializer example

if ($entity instanceof Struct) {
            $entity = $entity->jsonSerialize();
        }

        $fields = $definition->getFields();
        $extensionFields = $definition->getExtensionFields();

        foreach ($entity as $key => $value) {
            if ($key === 'extensions') {
                foreach ($value as $extensionKey => $extensionValue) {
                    if (isset($extensionFields[$extensionKey])) {
                        $serializer = $this->serializerRegistry->getFieldSerializer($extensionFields[$extensionKey]);
                        yield from $serializer->serialize($config$extensionFields[$extensionKey]$extensionValue);
                    }
                }

                continue;
            }

            $field = $fields->get($key);
            if ($field === null) {
                yield $key => $value; // pass-through
                
Home | Imprint | This part of the site doesn't use cookies.