You are here

function masquerade_context_features_pipe_context_alter in Masquerade Extras 6.2

Same name and namespace in other branches
  1. 6 masquerade_context/masquerade_context.features.inc \masquerade_context_features_pipe_context_alter()
  2. 7.2 masquerade_context/masquerade_context.features.inc \masquerade_context_features_pipe_context_alter()
  3. 7 masquerade_context/masquerade_context.features.inc \masquerade_context_features_pipe_context_alter()

Implements hook_features_pipe_COMPONENT_alter().

Alters the processing of a features component before it is exported. This is useful for adding dependencies or updating exportable data.

See also

hook_features_pipe_COMPONENT_alter()

context_load()

File

masquerade_context/masquerade_context.features.inc, line 17
Adds features support when exporting contexts that use the masquerade_is_masquerading condition.

Code

function masquerade_context_features_pipe_context_alter(&$pipe, $data, &$export) {

  // Scan over each selected context.
  foreach ($data as $machine_name) {

    // If other components in this feature already depend on masquerade_context,
    // just skip ahead. We don't need to scan over this multiple times.
    if (in_array('masquerade_context', $export['dependencies'])) {
      return;
    }

    // Try to load the context so we can see what components it is using.
    // If the "masquerade_is_masquerading" condition is in use, add
    // this module as a dependency.
    if ($context = context_load($machine_name)) {
      if (in_array('masquerade_is_masquerading', array_keys($context->conditions))) {
        $export['dependencies'][] = 'masquerade_context';
      }
    }
  }
}