abstract class NormalizerBase in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Normalizer/NormalizerBase.php \Drupal\jsonapi\Normalizer\NormalizerBase
Base normalizer used in all JSON API normalizers.
@internal
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\jsonapi\Normalizer\NormalizerBase
Expanded class hierarchy of NormalizerBase
File
- src/
Normalizer/ NormalizerBase.php, line 12
Namespace
Drupal\jsonapi\NormalizerView source
abstract class NormalizerBase extends SerializationNormalizerBase {
/**
* The formats that the Normalizer can handle.
*
* @var array
*/
protected $formats = [
'api_json',
];
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = NULL) {
return in_array($format, $this->formats, TRUE) && parent::supportsNormalization($data, $format);
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableNormalizerInterface:: |
constant | Name of key for bubbling cacheability metadata via serialization context. | ||
NormalizerBase:: |
protected | property | List of formats which supports (de-)normalization. | 3 |
NormalizerBase:: |
protected | property | The formats that the Normalizer can handle. | 4 |
NormalizerBase:: |
protected | property | The interface or class that this Normalizer supports. | 22 |
NormalizerBase:: |
protected | function | Adds cacheability if applicable. | |
NormalizerBase:: |
protected | function | Checks if the provided format is supported by this normalizer. | 2 |
NormalizerBase:: |
public | function |
Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() Overrides NormalizerBase:: |
|
NormalizerBase:: |
public | function |
Checks whether the given class is supported for normalization by this normalizer. Overrides NormalizerBase:: |