public function TermEntityNormalizer::normalize in Default Content Extras 8
Overrides ContentEntityNormalizer::normalize
File
- src/
Normalizer/ TermEntityNormalizer.php, line 55
Class
- TermEntityNormalizer
- Defines a class for normalizing terms.
Namespace
Drupal\default_content_extra\NormalizerCode
public function normalize($entity, $format = NULL, array $context = array()) {
$normalized = parent::normalize($entity, $format, $context);
if ($this->config
->get('path_alias')) {
$tid = $entity
->id();
$path = Url::fromRoute('entity.taxonomy_term.canonical', [
'taxonomy_term' => $tid,
])
->toString();
// If it's not a system path export it.
if ($path != "/taxonomy/term/{$tid}") {
$normalized['path'] = [
'alias' => $path,
];
}
}
return $normalized;
}