You are here

public function VariableRealmUnionController::getAllKeys in Variable 7.2

Implementation of VariableRealmControllerInterface::getAllKeys().

Overrides VariableRealmDefaultController::getAllKeys

File

variable_realm/variable_realm_union.class.inc, line 38
Classes for Realm Union.

Class

VariableRealmUnionController
Default Realm Union class

Code

public function getAllKeys() {
  $all_realm_keys = $this
    ->invokeUnionRealms('getAllKeys');

  // First build all combinations of realm keys.
  $combine = array(
    array(
      'keys' => array(),
      'names' => array(),
    ),
  );
  foreach ($all_realm_keys as $realm => $realm_keys) {
    $new_combine = array();
    foreach ($combine as $index => $data) {
      foreach ($realm_keys as $new_key => $new_name) {
        $keys = $data['keys'];
        $names = $data['names'];
        $keys[$realm] = $new_key;
        $names[$realm] = $new_name;
        $new_combine[] = array(
          'keys' => $keys,
          'names' => $names,
        );
      }
    }
    $combine = $new_combine;
  }

  // Now build all realm keys for the combinations.
  $keys = array();
  foreach ($combine as $data) {
    $key = $this
      ->buildUnionKey($data['keys']);
    $name = $this
      ->buildUnionName($data['names']);
    $keys[$key] = $name;
  }
  return $keys;
}