1 layout.module layout_relationships_get_relevant_info($contexts)

Fetch all relevant relationships.

Relevant relationships are any relationship that can be created based upon the list of existing contexts. For example, the 'node author' relationship is relevant if there is a 'node' context, but makes no sense if there is not one.

Parameters

$contexts: An array of contexts used to figure out which relationships are relevant.

Return value

An array of relationship keys that are relevant for the given set of: contexts.

File

core/modules/layout/layout.module, line 1597
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_relationships_get_relevant_info($contexts) {
  $relevant = array();
  $relationships = _layout_get_all_info('layout_relationship');

  foreach ($contexts as $context) {
    // Go through each relationship
    foreach ($relationships as $rid => $relationship) {
      $handler = layout_create_handler('layout_relationship', $rid);
      if ($children = $handler->getChildren($rid)) {
        foreach ($children as $child_rid => $child) {
          if ($child['context'] == $context->plugin) {
            $relevant[$child_rid] = $child;
          }
        }
      }
      else {
        if ($relationship['context'] == $context->plugin) {
          $relevant[$rid . ':relationship'] = $relationship;
        }
      }
    }
  }

  return $relevant;
}