1.20.x 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

modules/layout/includes/layout.class.inc, line 888
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_contexts = $this->getContexts();
  foreach ($required_contexts as $required_context_name) {
    $context_missing = TRUE;
    foreach ($all_contexts as $context) {
      if ($context->isA($required_context_name)) {
        // Matching context available, continue to the next one.
        $context_missing = FALSE;
        break;
      }
    }
    if ($context_missing) {
      return FALSE;
    }
  }

  return TRUE;
}