function access_by_ref_get_overlords in Access by Reference 8
1 call to access_by_ref_get_overlords()
File
- ./
access_by_ref.module, line 179
Code
function access_by_ref_get_overlords(NodeInterface $node, $overfield) {
// collect the nids of the nodes that reference this node in the named field
$table = "node__{$overfield}";
// naming convention
$targetfield = $overfield . "_target_id";
$parms = array(
':nid' => $node
->id(),
':ntype' => $node
->getType(),
);
$sql = "SELECT entity_id FROM {$table} WHERE {$targetfield} = :nid AND bundle = :ntype";
$rows = array();
$result = \Drupal::database()
->query($sql, $parms);
while ($row = $result
->fetchAssoc()) {
$rows[] = $row['entity_id'];
}
return $rows;
}