You are here

public function NormalizerBase::supportsDenormalization in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsDenormalization()

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

This class doesn't implement DenormalizerInterface, but most of its child classes do. Therefore, this method is implemented at this level to reduce code duplication.

1 method overrides NormalizerBase::supportsDenormalization()
ResourceObjectNormalizer::supportsDenormalization in core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php
Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

File

core/modules/serialization/src/Normalizer/NormalizerBase.php, line 54

Class

NormalizerBase
Base class for Normalizers.

Namespace

Drupal\serialization\Normalizer

Code

public function supportsDenormalization($data, $type, $format = NULL) {

  // If the format is not supported return now.
  if (!$this
    ->checkFormat($format)) {
    return FALSE;
  }
  $supported = (array) $this->supportedInterfaceOrClass;
  $subclass_check = function ($name) use ($type) {
    return (class_exists($name) || interface_exists($name)) && is_subclass_of($type, $name, TRUE);
  };
  return in_array($type, $supported) || array_filter($supported, $subclass_check);
}