📌  相关文章
📜  drupal 8 从路径别名获取节点 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:40.529000             🧑  作者: Mango

代码示例1
// Get node from path alias.
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');

if(preg_match('/node\/(\d+)/', $path, $matches)) {
  $node = \Drupal\node\Entity\Node::load($matches[1]);
}

// Path alias manager service has been change to 'path_alias.manager' on later version.
$path = \Drupal::service('path_alias.manager')->getPathByAlias('/this-is-the-alias');