function NormalizerBase::supportsDenormalization

Same name in other branches
  1. 8.9.x core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsDenormalization()
  2. 10 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsDenormalization()
  3. 11.x 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 55

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.