public function NormalizerBase::supportsDenormalization in JSON:API 8
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.
Overrides NormalizerBase::supportsDenormalization
File
- src/
Normalizer/ NormalizerBase.php, line 31
Class
- NormalizerBase
- Base normalizer used in all JSON API normalizers.
Namespace
Drupal\jsonapi\NormalizerCode
public function supportsDenormalization($data, $type, $format = NULL) {
if (in_array($format, $this->formats, TRUE) && (class_exists($this->supportedInterfaceOrClass) || interface_exists($this->supportedInterfaceOrClass))) {
$target = new \ReflectionClass($type);
$supported = new \ReflectionClass($this->supportedInterfaceOrClass);
if ($supported
->isInterface()) {
return $target
->implementsInterface($this->supportedInterfaceOrClass);
}
else {
return $target
->getName() == $this->supportedInterfaceOrClass || $target
->isSubclassOf($this->supportedInterfaceOrClass);
}
}
return FALSE;
}