You are here

function path_breadcrumbs_get_contexts_from_arguments in Path Breadcrumbs 7.2

Same name and namespace in other branches
  1. 7.3 path_breadcrumbs.module \path_breadcrumbs_get_contexts_from_arguments()

Load ctools contexts from path arguments.

Parameters

$arguments: URL arguments.

bool $empty: Define load context for empty arguments or not

Return value

array Array with context plugins.

3 calls to path_breadcrumbs_get_contexts_from_arguments()
path_breadcrumbs_ctools_access_get in path_breadcrumbs_ui/path_breadcrumbs_ui.module
Callback for access control ajax form on behalf of context task handler (third step). Returns the cached access config and contexts used.
path_breadcrumbs_load_variant in ./path_breadcrumbs.module
Load path breadcrumb variant for page url.
_path_breadcrumbs_ui_form_step_selection_rules in path_breadcrumbs_ui/path_breadcrumbs_ui.module
THIRD STEP. Provide form with selection rules.

File

./path_breadcrumbs.module, line 518
Provide core functions for path breadcrumbs modue.

Code

function path_breadcrumbs_get_contexts_from_arguments($arguments, $empty = FALSE) {
  $contexts = array();

  // Include ctools library for contexts.
  ctools_include('context');
  if (!empty($arguments)) {

    // Get contexts from arguments.
    foreach ($arguments as $keyword => $arg) {
      if (!empty($arg['argument'])) {
        $argument = ctools_get_argument($arg['argument']);
        if (isset($arg['settings'])) {
          $argument = array_merge($argument, $arg['settings']);
        }

        // See what we should return: empty contexts or from path arguments.
        $arg = $empty ? NULL : arg($arg['position']);

        // Build context.
        $context = call_user_func($argument['context'], $arg, $argument, $empty);
        if (!empty($context)) {
          $context->keyword = $keyword;
          $context->identifier = $argument['identifier'];
          $contexts[$keyword] = $context;
        }
        else {
          $contexts['broken_context'] = $keyword;
        }
      }
    }
  }
  return $contexts;
}