protected function ContentEntityNormalizer::getPathLinkNodeAttached in Content Synchronization 3.0.x
Gets a node attached to a path alias. The node has already been imported.
Parameters
\Drupal\path_alias\Entity\PathAlias $object: Menu Link Entity.
Return value
\Drupal\Core\Entity\EntityInterface|null Node Entity.
1 call to ContentEntityNormalizer::getPathLinkNodeAttached()
- ContentEntityNormalizer::normalize in src/
Normalizer/ ContentEntityNormalizer.php
File
- src/
Normalizer/ ContentEntityNormalizer.php, line 224
Class
- ContentEntityNormalizer
- Adds the file URI to embedded file entities.
Namespace
Drupal\content_sync\NormalizerCode
protected function getPathLinkNodeAttached(PathAlias $object) {
$path = $object
->getPath();
try {
$url = Url::fromUri('internal:' . $path);
$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 path is linked to a non-node page - just do nothing.
}
}