public function HierarchyOutlineStorage::hierarchyGetNodeChildren in Entity Reference Hierarchy 8
Get the children of the given node.
File
- src/
HierarchyOutlineStorage.php, line 156 - Definition of Drupal\entity_hierarchy\HierarchyOutlineStorage.
Class
- HierarchyOutlineStorage
- Defines a storage class for hierarchies outline.
Namespace
Drupal\entity_hierarchyCode
public function hierarchyGetNodeChildren($node, $limit = FALSE) {
$pnid = $node;
if (is_object($node)) {
$pnid = $node
->id();
}
$query = db_select('entity_hierarchy', 'nh')
->fields('nh')
->fields('nfd', array(
'title',
))
->where('pnid = :pnid', array(
':pnid' => $pnid,
))
->orderBy('cweight', 'ASC');
$query
->leftJoin('node', 'n', 'nh.cnid = n.nid');
$query
->leftJoin('node_field_data', 'nfd', 'nfd.nid = n.nid');
if ($limit) {
$query
->range(0, $limit);
}
$result = $query
->execute()
->fetchAll();
$children = array();
foreach ($result as $item) {
$children[] = $item;
}
return $children;
}