You are here

public function NormalizerBase::supportsNormalization in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsNormalization()
1 method overrides NormalizerBase::supportsNormalization()
EntityDenormalizerBase::supportsNormalization in core/modules/jsonapi/src/Normalizer/EntityDenormalizerBase.php
Checks whether the given class is supported for normalization by this normalizer.

File

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

Class

NormalizerBase
Base class for Normalizers.

Namespace

Drupal\serialization\Normalizer

Code

public function supportsNormalization($data, $format = NULL) {

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