You are here

public function RelationshipFieldDefinitionNormalizer::supportsNormalization in Schemata 8

Overrides NormalizerBase::supportsNormalization

File

schemata_json_schema/src/Normalizer/jsonapi/RelationshipFieldDefinitionNormalizer.php, line 47

Class

RelationshipFieldDefinitionNormalizer
Normalizer for RelationshipFieldDefinitionNormalizer objects.

Namespace

Drupal\schemata_json_schema\Normalizer\jsonapi

Code

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);
}