You are here

function page_manager_handler_get_name in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 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 440
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);
  $name = '';

  // Optional machine name.
  if (!empty($handler->conf['name'])) {
    $name = $base . '__' . $handler->conf['name'];
    if (count(ctools_export_load_object('page_manager_handlers', 'names', array(
      $name,
    )))) {
      $name = '';
    }
  }

  // If no machine name was provided or the name is in use, generate a unique name.
  if (empty($name)) {
    $base .= '__' . $handler->handler;

    // Use the ctools uuid generator to generate a unique id.
    $name = $base . '_' . ctools_uuid_generate();
  }
  return $name;
}