function NormalizerBase::supportsNormalization

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

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

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