function NormalizerBase::supportsNormalization
Same name in other branches
- 9 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsNormalization()
- 8.9.x core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase::supportsNormalization()
- 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 26
Class
- NormalizerBase
- Base class for Normalizers.
Namespace
Drupal\serialization\NormalizerCode
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;
}
if (property_exists($this, 'supportedInterfaceOrClass')) {
@trigger_error('Defining ' . static::class . '::supportedInterfaceOrClass property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getSupportedTypes() instead. See https://www.drupal.org/node/3359695', E_USER_DEPRECATED);
$supported = (array) $this->supportedInterfaceOrClass;
}
else {
$supported = array_keys($this->getSupportedTypes($format));
}
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.