You are here

function page_manager_handler_get_name in Chaos Tool Suite (ctools) 6

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

Generate a unique name for a task handler.

Task handlers need to be named but they aren't allowed to set their own names. Instead, they are named based upon their parent task and type.

1 call to page_manager_handler_get_name()
page_manager_handler_add_to_page in page_manager/page_manager.module
Import a handler into a page.

File

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

Code

function page_manager_handler_get_name($task_name, $handlers, $handler) {
  $base = str_replace('-', '_', $task_name);

  // Generate a unique name. Unlike most named objects, we don't let people choose
  // names for task handlers because they mostly don't make sense.
  $base .= '_' . $handler->handler;

  // Once we have a base, check to see if it is used. If it is, start counting up.
  $name = $base;
  $count = 1;

  // If taken
  while (isset($handlers[$name])) {
    $name = $base . '_' . ++$count;
  }
  return $name;
}