Skip to content
Snippets Groups Projects

Issue #3202244: TypeError: Argument 1 passed to Drupal\default_content\Normalizer\ContentEntityNormalizer::addDependency() must implement interface Drupal\Core\Entity\ContentEntityInterface, null given

Open Issue #3202244: TypeError: Argument 1 passed to Drupal\default_content\Normalizer\ContentEntityNormalizer::addDependency() must implement interface Drupal\Core\Entity\ContentEntityInterface, null given
@@ -121,7 +121,9 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface {
if (strpos($entity->getParentId(), PluginBase::DERIVATIVE_SEPARATOR) !== FALSE) {
[$plugin_id, $parent_uuid] = explode(PluginBase::DERIVATIVE_SEPARATOR, $entity->getParentId());
if ($plugin_id === 'menu_link_content' && $parent_entity = $this->entityRepository->loadEntityByUuid('menu_link_content', $parent_uuid)) {
$this->addDependency($parent_entity);
if ($parent_entity instanceof ContentEntityInterface) {
$this->addDependency($parent_entity);
}
}
}
}
@@ -415,8 +417,10 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface {
$value = $this->normalize($target);
}
else {
$this->addDependency($target);
$value = $target->uuid();
if ($parent_entity instanceof ContentEntityInterface) {
$this->addDependency($parent_entity);
$value = $target->uuid();
}
}
}
elseif ($property instanceof Uri) {
@@ -427,8 +431,10 @@ class ContentEntityNormalizer implements ContentEntityNormalizerInterface {
$path = parse_url($value, PHP_URL_PATH);
[$target_entity_type_id, $target_id] = explode('/', $path);
$target = $this->entityTypeManager->getStorage($target_entity_type_id)->load($target_id);
$this->addDependency($target);
$normalized_item['target_uuid'] = $target->uuid();
if ($target instanceof ContentEntityInterface) {
$this->addDependency($target);
$normalized_item['target_uuid'] = $target->uuid();
}
$value = NULL;
}
}
Loading