You are here

public function NormalizerBase::supportsNormalization in Drupal 10

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

File

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

Class

NormalizerBase
Base class for Normalizers.

Namespace

Drupal\serialization\Normalizer

Code

public function supportsNormalization($data, string $format = NULL, array $context = []) : bool {

  // If we aren't dealing with an object or the format is not supported return
  // now.
  if (!is_object($data) || !$this
    ->checkFormat($format)) {
    return FALSE;
  }
  $supported = (array) $this->supportedInterfaceOrClass;
  return (bool) array_filter($supported, function ($name) use ($data) {
    return $data instanceof $name;
  });
}