1 layout_menu_item.class.inc | LayoutMenuItem::hasContexts(array $required_contexts) |
Check if the menu item has a context of a particular name.
Parameters
array $required_contexts: An unindexed array of context plugin names.
Return value
boolean: TRUE if this menu item has all the required contexts, FALSE otherwise.
File
- core/
modules/ layout/ includes/ layout_menu_item.class.inc, line 295 - Class for storing information about menu item entries.
Class
- LayoutMenuItem
- @file Class for storing information about menu item entries.
Code
function hasContexts(array $required_contexts) {
$all_contexts = $this->getContexts();
foreach ($required_contexts as $required_context_name) {
$context_missing = TRUE;
foreach ($all_contexts as $context) {
if ($context->plugin === $required_context_name) {
// Matching context available, continue to the next one.
$context_missing = FALSE;
break;
}
}
if ($context_missing) {
return FALSE;
}
}
return TRUE;
}