public function TermEntityNormalizer::denormalize in Default Content Extras 8
Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize().
Parameters
array $data: Entity data to restore.
string $class: Unused parameter.
string $format: Format the given data was extracted from.
array $context: Options available to the denormalizer. Keys that can be used:
- request_method: if set to "patch" the denormalization will clear out all default values for entity fields before applying $data to the entity.
Return value
\Drupal\Core\Entity\EntityInterface An unserialized entity object containing the data in $data.
Throws
\Symfony\Component\Serializer\Exception\UnexpectedValueException
Overrides ContentEntityNormalizer::denormalize
File
- src/
Normalizer/ TermEntityNormalizer.php, line 74
Class
- TermEntityNormalizer
- Defines a class for normalizing terms.
Namespace
Drupal\default_content_extra\NormalizerCode
public function denormalize($data, $class, $format = NULL, array $context = array()) {
$entity = parent::denormalize($data, $class, $format, $context);
if ($this->config
->get('path_alias')) {
// Add the path alias if it's included.
if (!empty($data['path']['alias'])) {
$entity->path = [
'alias' => $data['path']['alias'],
];
}
}
return $entity;
}