protected function DefaultContentManager::getMenuLink in Default Content 8
1 call to DefaultContentManager::getMenuLink()
- DefaultContentManager::exportContentWithMenuLinks in src/
DefaultContentManager.php - Exports a single entity as importContent expects it.
File
- src/
DefaultContentManager.php, line 288 - Contains \Drupal\defaultcontent\DefaultContentManager. @todo remove all references to linkmanager?
Class
- DefaultContentManager
- A service for handling import of default content. @todo throw useful exceptions
Namespace
Drupal\defaultcontentCode
protected function getMenuLink($entity) {
if (!\Drupal::moduleHandler()
->moduleExists('menu_link_content')) {
return;
}
$links = $this->entityTypeManager
->getStorage('menu_link_content')
->loadByProperties([
'link.uri' => 'entity:node/' . $entity
->id(),
]);
if (empty($links)) {
return;
}
$link = reset($links);
$item = [
'title' => $link
->getTitle(),
'description' => $link
->getDescription(),
'menu_name' => $link
->getMenuName(),
'dest_uuid' => $entity
->uuid(),
'weight' => $link
->getWeight(),
];
return Yaml::encode($item);
}