protected function SqlGroupGraphStorage::insertEdgesParentToChildOutgoing in Subgroup (Graph) 1.0.x
Insert parent group outgoing 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::insertEdgesParentToChildOutgoing()
- SqlGroupGraphStorage::addEdge in src/
Graph/ SqlGroupGraphStorage.php - Relates the parent group and the child group.
File
- src/
Graph/ SqlGroupGraphStorage.php, line 328
Class
- SqlGroupGraphStorage
- SQL based storage of the group relationship graph.
Namespace
Drupal\ggroup\GraphCode
protected function insertEdgesParentToChildOutgoing($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($edge_id, 'entry_edge_id');
$query
->addExpression($edge_id, 'direct_edge_id');
$query
->addExpression('gg.id', 'exit_edge_id');
$query
->addExpression($parent_group_id, 'start_vertex');
$query
->addExpression('gg.end_vertex', 'end_vertex');
$query
->addExpression('gg.hops + 1', 'hops');
$query
->condition('start_vertex', $child_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();
}