protected function ContentEntityNormalizer::denormalizeMenuLinkParent in Replication 8.2
Same name and namespace in other branches
- 8 src/Normalizer/ContentEntityNormalizer.php \Drupal\replication\Normalizer\ContentEntityNormalizer::denormalizeMenuLinkParent()
Parameters
$data:
$context:
Return value
string
1 call to ContentEntityNormalizer::denormalizeMenuLinkParent()
- ContentEntityNormalizer::denormalizeTranslation in src/
Normalizer/ ContentEntityNormalizer.php
File
- src/
Normalizer/ ContentEntityNormalizer.php, line 567
Class
Namespace
Drupal\replication\NormalizerCode
protected function denormalizeMenuLinkParent($data, $context) {
if (strpos($data, 'menu_link_content') === 0) {
list($type, $uuid, $id) = explode(':', $data);
if ($type === 'menu_link_content' && $uuid && is_numeric($id)) {
$storage = $this->entityManager
->getStorage('menu_link_content');
$parent = $storage
->loadByProperties([
'uuid' => $uuid,
]);
$parent = reset($parent);
if ($parent instanceof MenuLinkContentInterface && $parent
->id() && $parent
->id() != $id) {
return $type . ':' . $uuid . ':' . $parent
->id();
}
elseif (!$parent) {
// Create a new menu link as stub.
$parent = $storage
->create([
'uuid' => $uuid,
'link' => 'internal:/',
]);
// Set the target workspace if we have it in context.
if (isset($context['workspace']) && $context['workspace'] instanceof WorkspaceInterface) {
$parent->workspace->target_id = $context['workspace']
->id();
}
// Indicate that this revision is a stub.
$parent->_rev->is_stub = TRUE;
$parent
->save();
return $type . ':' . $uuid . ':' . $parent
->id();
}
}
}
return $data;
}