abstract class NormalizerBase in Zircon Profile 8
Same name in this branch
- 8 core/modules/hal/src/Normalizer/NormalizerBase.php \Drupal\hal\Normalizer\NormalizerBase
- 8 core/modules/serialization/src/Normalizer/NormalizerBase.php \Drupal\serialization\Normalizer\NormalizerBase
Same name and namespace in other branches
- 8.0 core/modules/hal/src/Normalizer/NormalizerBase.php \Drupal\hal\Normalizer\NormalizerBase
Base class for Normalizers.
Hierarchy
- class \Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer implements SerializerAwareInterface
- class \Drupal\serialization\Normalizer\NormalizerBase implements NormalizerInterface
- class \Drupal\hal\Normalizer\NormalizerBase implements DenormalizerInterface
- class \Drupal\serialization\Normalizer\NormalizerBase implements NormalizerInterface
Expanded class hierarchy of NormalizerBase
File
- core/
modules/ hal/ src/ Normalizer/ NormalizerBase.php, line 16 - Contains \Drupal\hal\Normalizer\NormalizerBase.
Namespace
Drupal\hal\NormalizerView source
abstract class NormalizerBase extends SerializationNormalizerBase implements DenormalizerInterface {
/**
* The formats that the Normalizer can handle.
*
* @var array
*/
protected $formats = array(
'hal_json',
);
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = NULL) {
return in_array($format, $this->formats) && parent::supportsNormalization($data, $format);
}
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = NULL) {
if (in_array($format, $this->formats) && (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 |
---|---|---|---|---|
DenormalizerInterface:: |
public | function | Denormalizes data back into an object of the given class. | 10 |
NormalizerBase:: |
protected | property | The formats that the Normalizer can handle. | |
NormalizerBase:: |
protected | property | The interface or class that this Normalizer supports. | 7 |
NormalizerBase:: |
protected | function | Checks if the provided format is supported by this normalizer. | |
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:: |
|
NormalizerInterface:: |
public | function | Normalizes an object into a set of arrays/scalars. | 15 |
SerializerAwareNormalizer:: |
protected | property | ||
SerializerAwareNormalizer:: |
public | function |
Sets the owning Serializer object. Overrides SerializerAwareInterface:: |