You are here

function page_manager_compare_task_handlers in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/page_manager.module \page_manager_compare_task_handlers()

Compare a single task handler from two lists and provide the correct one.

Task handlers can be gotten from multiple sources. As exportable objects, they can be provided by default hooks and the database. But also, because they are tightly bound to tasks, they can also be provided by default tasks. This function reconciles where to pick up a task handler between the exportables list and the defaults provided by the task itself.

Parameters

$result: A list of handlers provided by export.inc

$handlers: A list of handlers provided by the default task.

$name: Which handler to compare.

Return value

Which handler to use, if any. May be NULL.

2 calls to page_manager_compare_task_handlers()
page_manager_load_task_handler in page_manager/page_manager.module
Load a single task handler by name.
page_manager_load_task_handlers in page_manager/page_manager.module
Load all task handlers for a given task/subtask.

File

page_manager/page_manager.module, line 516
The page manager module provides a UI and API to manage pages.

Code

function page_manager_compare_task_handlers($result, $handlers, $name) {

  // Compare our special default handler against the actual result, if
  // any, and do the right thing.
  if (!isset($result[$name]) && isset($handlers[$name])) {
    $handlers[$name]->type = t('Default');
    $handlers[$name]->export_type = EXPORT_IN_CODE;
    return $handlers[$name];
  }
  else {
    if (isset($result[$name]) && !isset($handlers[$name])) {
      return $result[$name];
    }
    else {
      if (isset($result[$name]) && isset($handlers[$name])) {
        if ($result[$name]->export_type & EXPORT_IN_DATABASE) {
          $result[$name]->type = t('Overridden');
          $result[$name]->export_type = $result[$name]->export_type | EXPORT_IN_CODE;
          return $result[$name];
        }
        else {

          // In this case, our default is a higher priority than the standard default.
          $handlers[$name]->type = t('Default');
          $handlers[$name]->export_type = EXPORT_IN_CODE;
          return $handlers[$name];
        }
      }
    }
  }
}