1.20.x block.class.inc | Block::setContexts(array $all_contexts) |
Set the contexts for this block.
File
- modules/
layout/ includes/ block.class.inc, line 358 - A class that wraps around a block to store settings information.
Class
- Block
- @file A class that wraps around a block to store settings information.
Code
function setContexts(array $all_contexts) {
$block_info = $this->getBlockInfo();
$all_contexts_set = TRUE;
if (!empty($block_info['required contexts'])) {
$all_contexts_set = layout_set_handler_contexts($this->contexts, $all_contexts, $block_info['required contexts'], $this->settings['contexts']);
}
if (!$all_contexts_set) {
return FALSE;
}
// Let each condition select its contexts as needed as well.
foreach ($this->conditions as $condition) {
$all_contexts_set = $condition->setContexts($all_contexts);
if (!$all_contexts_set) {
return FALSE;
}
}
// Contexts set for the block and all its children.
return TRUE;
}