You are here

private function SqlGroupGraphStorage::flattenGroups in Subgroup (Graph) 1.0.x

Flattens an array of groups into a simple, single level array.

Parameters

array $groups: The groups that need to be flattened.

Return value

array An array of groups that were successfully flattened.

1 call to SqlGroupGraphStorage::flattenGroups()
SqlGroupGraphStorage::loadGroupMapping in src/Graph/SqlGroupGraphStorage.php
Fetch the records from graph for the provided group and cache them.

File

src/Graph/SqlGroupGraphStorage.php, line 172

Class

SqlGroupGraphStorage
SQL based storage of the group relationship graph.

Namespace

Drupal\ggroup\Graph

Code

private function flattenGroups(array $groups) {
  $flat_groups = [];
  if (!empty($groups)) {
    foreach ($groups as $group_val) {
      if (is_array($group_val)) {
        $flat_groups += $group_val;
      }
      else {
        $flat_groups[] = $group_val;
      }
    }
  }
  return $flat_groups;
}