You are here

public function SqlGroupGraphStorage::isAncestor in Subgroup (Graph) 1.0.x

Checks if a group (A) is the direct ancestor of another group (B).

Parameters

int $a: The group whose ancestry status will be checked.

int $b: The group for which ancestry status will be checked against.

Return value

bool TRUE if group A is an ancestor of group B.

Overrides GroupGraphStorageInterface::isAncestor

1 call to SqlGroupGraphStorage::isAncestor()
SqlGroupGraphStorage::getPath in src/Graph/SqlGroupGraphStorage.php
Use the Breadth-first search algoritm to find the path between groups.

File

src/Graph/SqlGroupGraphStorage.php, line 561

Class

SqlGroupGraphStorage
SQL based storage of the group relationship graph.

Namespace

Drupal\ggroup\Graph

Code

public function isAncestor($a, $b) {
  $this
    ->loadMap($b);
  return isset($this->ancestors[$b]) ? in_array($a, $this->ancestors[$b]) : FALSE;
}