protected function SqlGroupGraphStorage::insertEdgesParentIncomingToChild in Subgroup (Graph) 1.0.x
Insert parent group incoming edges to child group.
Parameters
int $edge_id: The existing edge ID relating the parent group to the child group.
int $parent_group_id: The ID of the parent group.
int $child_group_id: The ID of the child group.
1 call to SqlGroupGraphStorage::insertEdgesParentIncomingToChild()
- SqlGroupGraphStorage::addEdge in src/
Graph/ SqlGroupGraphStorage.php - Relates the parent group and the child group.
File
- src/
Graph/ SqlGroupGraphStorage.php, line 293
Class
- SqlGroupGraphStorage
- SQL based storage of the group relationship graph.
Namespace
Drupal\ggroup\GraphCode
protected function insertEdgesParentIncomingToChild($edge_id, $parent_group_id, $child_group_id) {
// Since fields are added before expressions, all fields are added as
// expressions to keep the field order intact.
$query = $this->connection
->select('group_graph', 'gg');
$query
->addExpression('gg.id', 'entry_edge_id');
$query
->addExpression($edge_id, 'direct_edge_id');
$query
->addExpression($edge_id, 'exit_edge_id');
$query
->addExpression('gg.start_vertex', 'start_vertex');
$query
->addExpression($child_group_id, 'end_vertex');
$query
->addExpression('gg.hops + 1', 'hops');
$query
->condition('end_vertex', $parent_group_id);
$this->connection
->insert('group_graph')
->fields([
'entry_edge_id',
'direct_edge_id',
'exit_edge_id',
'start_vertex',
'end_vertex',
'hops',
])
->from($query)
->execute();
}