public function RelationshipFieldDefinitionNormalizer::supportsNormalization in JSON:API Schema 8
Overrides DataDefinitionNormalizer::supportsNormalization
File
- src/
Normalizer/ RelationshipFieldDefinitionNormalizer.php, line 48
Class
- RelationshipFieldDefinitionNormalizer
- Normalizer for RelationshipFieldDefinitionNormalizer objects.
Namespace
Drupal\jsonapi_schema\NormalizerCode
public function supportsNormalization($data, $format = NULL) {
if (!parent::supportsNormalization($data, $format)) {
return FALSE;
}
$type = $data
->getItemDefinition()
->getFieldDefinition()
->getType();
$class = $this->fieldTypeManager
->getPluginClass($type);
// Deal only with entity reference fields and descendants.
return $class == EntityReferenceItem::class || is_subclass_of($class, EntityReferenceItem::class);
}