Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize()
Overrides NormalizerInterface::normalize
public function normalize($field_item, $format = NULL, array $context = array()) {
$values = $field_item
->getPropertyValues();
if (isset($context['langcode'])) {
$values['lang'] = $context['langcode'];
}
// The values are wrapped in an array, and then wrapped in another array
// keyed by field name so that field items can be merged by the
// FieldNormalizer. This is necessary for the EntityReferenceItemNormalizer
// to be able to place values in the '_links' array.
$field = $field_item
->getParent();
return array(
$field
->getName() => array(
$values,
),
);
}