private function HierarchyBreadcrumbBuilder::hierarchyGetNodeParents in Entity Reference Hierarchy 8
Get all the parents for the given node.
1 call to HierarchyBreadcrumbBuilder::hierarchyGetNodeParents()
- HierarchyBreadcrumbBuilder::hierarchyGetNodeParentNids in src/
HierarchyBreadcrumbBuilder.php - Get the parent nodes for the given node.
File
- src/
HierarchyBreadcrumbBuilder.php, line 112 - Contains \Drupal\entity_hierarchy\HierarchyBreadcrumbBuilder.
Class
- HierarchyBreadcrumbBuilder
- Provides a breadcrumb builder for nodes in a book.
Namespace
Drupal\entity_hierarchyCode
private function hierarchyGetNodeParents($node, $limit = NULL) {
$cnid = $node;
// If a node object was passed, then the parents may already have been loaded.
if (is_object($node)) {
if (isset($node->entity_hierarchy_parents)) {
return $node->entity_hierarchy_parents;
}
$cnid = $node->nid;
}
$out = array();
$db = \Drupal::database();
$query = $db
->select('entity_hierarchy', 'nh')
->fields('nh')
->where('cnid = :cnid', array(
':cnid' => $cnid,
))
->orderBy('pweight', 'ASC');
if ($limit) {
$query
->range(0, $limit);
}
$result = $query
->execute()
->fetchAll();
foreach ($result as $item) {
$out[] = $item;
}
return $out;
}