class ComplexDataDefinitionNormalizer in Schemata 8
Same name in this branch
- 8 schemata_json_schema/src/Normalizer/jsonapi/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\jsonapi\ComplexDataDefinitionNormalizer
- 8 schemata_json_schema/src/Normalizer/json/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\json\ComplexDataDefinitionNormalizer
- 8 schemata_json_schema/src/Normalizer/hal/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\hal\ComplexDataDefinitionNormalizer
Normalizer for ComplexDataDefinitionInterface.
ComplexDataDefinitions represent objects - compound values whose objects have string keys. Almost all fields are complex in this way, with their key data stored in an object property of "value". In turn, these objects are wrapped in an array which is normalized by ListDataDefinitionNormalizer.
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\schemata\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface
- class \Drupal\schemata_json_schema\Normalizer\json\JsonNormalizerBase implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface
- class \Drupal\schemata_json_schema\Normalizer\json\DataDefinitionNormalizer
- class \Drupal\schemata_json_schema\Normalizer\json\ComplexDataDefinitionNormalizer
- class \Drupal\schemata_json_schema\Normalizer\json\DataDefinitionNormalizer
- class \Drupal\schemata_json_schema\Normalizer\json\JsonNormalizerBase implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface
- class \Drupal\schemata\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface
Expanded class hierarchy of ComplexDataDefinitionNormalizer
1 file declares its use of ComplexDataDefinitionNormalizer
- ComplexDataDefinitionNormalizer.php in schemata_json_schema/
src/ Normalizer/ hal/ ComplexDataDefinitionNormalizer.php
1 string reference to 'ComplexDataDefinitionNormalizer'
- schemata_json_schema.services.yml in schemata_json_schema/
schemata_json_schema.services.yml - schemata_json_schema/schemata_json_schema.services.yml
1 service uses ComplexDataDefinitionNormalizer
File
- schemata_json_schema/
src/ Normalizer/ json/ ComplexDataDefinitionNormalizer.php, line 17
Namespace
Drupal\schemata_json_schema\Normalizer\jsonView source
class ComplexDataDefinitionNormalizer extends DataDefinitionNormalizer {
/**
* The interface or class that this Normalizer supports.
*
* @var string
*/
protected $supportedInterfaceOrClass = ComplexDataDefinitionInterface::class;
/**
* {@inheritdoc}
*/
public function normalize($entity, $format = NULL, array $context = []) {
/* @var $entity \Drupal\Core\TypedData\ComplexDataDefinitionInterface */
$context['parent'] = $entity;
$normalized = $this
->extractPropertyData($entity);
$normalized['type'] = 'object';
// Retrieve 'properties' and possibly 'required' nested arrays.
$properties = $this
->normalizeProperties($entity
->getPropertyDefinitions(), $format, $context);
$normalized = NestedArray::mergeDeep($normalized, $properties);
return $normalized;
}
/**
* Determine if the current field is a reference field.
*
* @param \Drupal\Core\TypedData\ComplexDataDefinitionInterface $entity
* The complex data definition to be checked.
* @param array $context
* The current serializer context.
*
* @return bool
* TRUE if it is a reference, FALSE otherwise.
*/
protected function isReferenceField(ComplexDataDefinitionInterface $entity, array $context = NULL) {
$main = $entity
->getPropertyDefinition($entity
->getMainPropertyName());
// @todo use an interface or API call instead of an object check.
return $main instanceof DataReferenceTargetDefinition;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableNormalizerInterface:: |
constant | Name of key for bubbling cacheability metadata via serialization context. | ||
ComplexDataDefinitionNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides DataDefinitionNormalizer:: |
|
ComplexDataDefinitionNormalizer:: |
protected | function | Determine if the current field is a reference field. | |
ComplexDataDefinitionNormalizer:: |
public | function |
Normalizes an object into a set of arrays/scalars. Overrides DataDefinitionNormalizer:: |
1 |
DataDefinitionNormalizer:: |
protected | function | Extracts property details from a data definition. | |
JsonNormalizerBase:: |
protected | property | The formats that the Normalizer can handle. | 7 |
JsonNormalizerBase:: |
protected | property |
The formats that the Normalizer can handle. Overrides NormalizerBase:: |
7 |
NormalizerBase:: |
protected | function | Adds cacheability if applicable. | |
NormalizerBase:: |
protected | function |
Checks if the provided format is supported by this normalizer. Overrides NormalizerBase:: |
|
NormalizerBase:: |
public | function | Denormalizes data back into an object of the given class. | |
NormalizerBase:: |
protected | function | Normalize an array of data definitions. | |
NormalizerBase:: |
protected | function | Determine if the given property is a required element of the schema. | |
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. | 1 |