3 namespace Drupal\serialization\Normalizer;
6 * Converts list objects to arrays.
8 * Ordinarily, this would be handled automatically by Serializer, but since
9 * there is a TypedDataNormalizer and the Field class extends TypedData, any
10 * Field will be handled by that Normalizer instead of being traversed. This
11 * class ensures that TypedData classes that also implement ListInterface are
12 * traversed instead of simply returning getValue().
14 class ListNormalizer extends NormalizerBase {
17 * The interface or class that this Normalizer supports.
21 protected $supportedInterfaceOrClass = 'Drupal\Core\TypedData\ListInterface';
26 public function normalize($object, $format = NULL, array $context = []) {
28 foreach ($object as $fieldItem) {
29 $attributes[] = $this->serializer->normalize($fieldItem, $format, $context);