1 layout.class.inc | Layout::hasContexts($required_contexts) |
Check if the layout has a context of a particular name.
Parameters
array $required_contexts: An unindexed array of context plugin names.
Return value
boolean: TRUE if this layout has all the required contexts, FALSE otherwise.
File
- core/
modules/ layout/ includes/ layout.class.inc, line 921 - Class for loading, modifying, and executing a layout.
Class
- Layout
- @file Class for loading, modifying, and executing a layout.
Code
function hasContexts($required_contexts) {
$all_available_contexts = $this->getContexts();
$context_counts = array_count_values($required_contexts);
foreach (array_unique($required_contexts) as $required_context_name) {
foreach ($all_available_contexts as $available_context) {
if ($available_context->isA($required_context_name)) {
// Matching context available, continue to the next one.
$context_counts[$required_context_name] = ($context_counts[$required_context_name] > 0) ? $context_counts[$required_context_name] - 1 : 0;
}
}
}
return empty(array_filter($context_counts));
}