I have several contexts defined for my site. In hook_form_alter I need to find out which of them are active. I am trying to use context_active_contexts, but that is only showing 2 of the (at least) 3 that are active. i.e. I have contexts A, B and C. C has a block reaction and the block is visible. My code only outputs A and B. If I disable C, the block disappears from the output, giving me some confidence that it really is context C that is responsible for it. Why can I not see A, B and C in the output?
function MyModule_get_current_location_contexts() {
$contexts = context_active_contexts();
$locations = array();
foreach ($contexts as $context) {
$locations[$context->name] = $context;
}
return $locations;
}
function MyModule_form_alter(&$form, &$form_state, $form_id){
dsm('Contexts (form):');
if ($form_id == 'MyForm') {
$contexts = MyModule_get_current_location_contexts();
foreach ($contexts as $context) {
dsm($context->name);
}
dsm($form);
}
}
function MyModule_node_view($node, $view_mode, $langcode) {
dsm('Contexts (entity):');
$contexts = MyModule_get_current_location_contexts();
foreach ($contexts as $context) {
dsm($context->name);
}
}