Converts list objects to arrays.
Ordinarily, this would be handled automatically by Serializer, but since there is a TypedDataNormalizer and the Field class extends TypedData, any Field will be handled by that Normalizer instead of being traversed. This class ensures that TypedData classes that also implement ListInterface are traversed instead of simply returning getValue().
Expanded class hierarchy of ListNormalizer
class ListNormalizer extends NormalizerBase {
/**
* The interface or class that this Normalizer supports.
*
* @var string
*/
protected $supportedInterfaceOrClass = 'Drupal\\Core\\TypedData\\ListInterface';
/**
* Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize().
*/
public function normalize($object, $format = NULL, array $context = array()) {
$attributes = array();
foreach ($object as $fieldItem) {
$attributes[] = $this->serializer
->normalize($fieldItem, $format);
}
return $attributes;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ListNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides NormalizerBase:: |
|
ListNormalizer:: |
public | function |
Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize(). Overrides NormalizerInterface:: |
|
NormalizerBase:: |
public | function |
Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization(). Overrides NormalizerInterface:: |
1 |
SerializerAwareNormalizer:: |
protected | property | ||
SerializerAwareNormalizer:: |
public | function |
Sets the owning Serializer object Overrides SerializerAwareInterface:: |