You are here

function _menu_example_mappings in Examples for Developers 6

Same name and namespace in other branches
  1. 7 menu_example/menu_example.module \_menu_example_mappings()

Utility function to provide mappings from integers to some strings. This would normally be some database lookup to get an object or array from a key.

Parameters

$id:

Return value

The string to which the integer key mapped, or NULL if it did not map.

Related topics

2 calls to _menu_example_mappings()
menu_example_arg_optional_load in menu_example/menu_example.module
Load an item based on its $id.
menu_example_id_load in menu_example/menu_example.module
The special _load function to load menu_example.

File

menu_example/menu_example.module, line 339
Demonstrates uses of the Menu APIs in Drupal, including hook_menu(), hook_menu_alter(), and hook_menu_link_alter().

Code

function _menu_example_mappings($id) {
  $mapped_value = NULL;
  static $mappings = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    99 => 'jackpot! default',
  );
  if (isset($mappings[$id])) {
    $mapped_value = $mappings[$id];
  }
  return $mapped_value;
}