protected function ContentEntityNormalizer::getMenuLinkNodeAttached in Content Synchronization 3.0.x
Same name and namespace in other branches
- 8.2 src/Normalizer/ContentEntityNormalizer.php \Drupal\content_sync\Normalizer\ContentEntityNormalizer::getMenuLinkNodeAttached()
Gets a node attached to a menu link. The node has already been imported.
Parameters
\Drupal\menu_link_content\Entity\MenuLinkContent $object: Menu Link Entity.
Return value
\Drupal\Core\Entity\EntityInterface|null Node Entity.
1 call to ContentEntityNormalizer::getMenuLinkNodeAttached()
- ContentEntityNormalizer::normalize in src/
Normalizer/ ContentEntityNormalizer.php
File
- src/
Normalizer/ ContentEntityNormalizer.php, line 198
Class
- ContentEntityNormalizer
- Adds the file URI to embedded file entities.
Namespace
Drupal\content_sync\NormalizerCode
protected function getMenuLinkNodeAttached(MenuLinkContent $object) {
$uri = $object
->get('link')
->getString();
$url = Url::fromUri($uri);
try {
$route_parameters = $url
->getRouteParameters();
if (count($route_parameters) == 1) {
$entity_id = reset($route_parameters);
$entity_type = key($route_parameters);
return \Drupal::entityTypeManager()
->getStorage($entity_type)
->load($entity_id);
}
} catch (\Exception $e) {
// If menu link is linked to a non-node page - just do nothing.
}
}