Skip to content
Snippets Groups Projects
Select Git revision
  • f13d5024035faeaae8aeff84ae9ffc719879de54
  • 11.x default protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.2.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
41 results

system.module

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    menu_test.module 24.00 KiB
    <?php
    
    /**
     * @file
     * Module that implements various hooks for menu tests.
     */
    
    use Drupal\menu_link\Plugin\Core\Entity\MenuLink;
    
    /**
     * Implements hook_menu().
     */
    function menu_test_menu() {
      // The name of the menu changes during the course of the test. Using a $_GET.
      $items['menu_name_test'] = array(
        'title' => 'Test menu_name router item',
        'page callback' => 'menu_test_callback',
        'menu_name' => menu_test_menu_name(),
      );
      // This item is of type MENU_CALLBACK with no parents to test title.
      $items['menu_callback_title'] = array(
        'title' => 'Menu Callback Title',
        'page callback' => 'menu_test_callback',
        'type' => MENU_CALLBACK,
        'access arguments' => array('access content'),
      );
      // This item uses system_admin_menu_block_page() to list child items.
      $items['menu_callback_description'] = array(
        'title' => 'Menu item title',
        'page callback' => 'system_admin_menu_block_page',
        'description' => 'Menu item description parent',
        'access arguments' => array('access content'),
        'file' => 'system.admin.inc',
        'file path' => drupal_get_path('module', 'system'),
      );
      // This item tests the description key.
      $items['menu_callback_description/description-plain'] = array(
        'title' => 'Menu item with a regular description',
        'page callback' => 'menu_test_callback',
        'description' => 'Menu item description text',
        'access arguments' => array('access content'),
      );
      // This item tests using a description callback.
      $items['menu_callback_description/description-callback'] = array(
        'title' => 'Menu item with a description set with a callback',
        'page callback' => 'menu_test_callback',
        'description callback' => 'check_plain',
        'description arguments' => array('<strong>Menu item description arguments</strong>'),
        'access arguments' => array('access content'),
      );
      // Use FALSE as 'title callback' to bypass t().
      $items['menu_no_title_callback'] = array(
        'title' => 'A title with @placeholder',
        'title callback' => FALSE,
        'title arguments' => array('@placeholder' => 'some other text'),
        'page callback' => 'menu_test_callback',
        'access arguments' => array('access content'),
      );
    
      // Hidden link for menu_link_maintain tests
      $items['menu_test_maintain/%'] = array(
        'title' => 'Menu maintain test',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
       );
      // Hierarchical tests.
      $items['menu-test/hierarchy/parent'] = array(
        'title' => 'Parent menu router',
        'page callback' => 'test_page_test_page',
      );
      $items['menu-test/hierarchy/parent/child'] = array(
        'title' => 'Child menu router',
        'page callback' => 'test_page_test_page',
      );
      $items['menu-test/hierarchy/parent/child2/child'] = array(
        'title' => 'Unattached subchild router',
        'page callback' => 'test_page_test_page',
      );
      // Theme callback tests.
      $items['menu-test/theme-callback/%'] = array(
        'title' => 'Page that displays different themes',
        'page callback' => 'menu_test_theme_page_callback',
        'access arguments' => array('access content'),
        'theme callback' => 'menu_test_theme_callback',
        'theme arguments' => array(2),
      );
      $items['menu-test/theme-callback/%/inheritance'] = array(
        'title' => 'Page that tests theme callback inheritance.',
        'page callback' => 'menu_test_theme_page_callback',
        'page arguments' => array(TRUE),
        'access arguments' => array('access content'),
      );
      $items['menu-test/no-theme-callback'] = array(
        'title' => 'Page that displays different themes without using a theme callback.',
        'page callback' => 'menu_test_theme_page_callback',
        'access arguments' => array('access content'),
      );
      // Path containing "exotic" characters.
      $path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
        "%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
        "éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
      $items[$path] = array(
        'title' => '"Exotic" path',
        'page callback' => 'menu_test_callback',
        'access arguments' => array('access content'),
      );
    
      // Hidden tests; base parents.
      // Same structure as in Menu and Block modules. Since those structures can
      // change, we need to simulate our own in here.
      $items['menu-test'] = array(
        'title' => 'Menu test root',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
      $items['menu-test/hidden'] = array(
        'title' => 'Hidden test root',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
    
      // Hidden tests; one dynamic argument.
      $items['menu-test/hidden/menu'] = array(
        'title' => 'Menus',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
      $items['menu-test/hidden/menu/list'] = array(
        'title' => 'List menus',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      $items['menu-test/hidden/menu/add'] = array(
        'title' => 'Add menu',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_ACTION,
      );
      $items['menu-test/hidden/menu/settings'] = array(
        'title' => 'Settings',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => 5,
      );
      $items['menu-test/hidden/menu/manage/%menu'] = array(
        'title' => 'Customize menu',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
      $items['menu-test/hidden/menu/manage/%menu/list'] = array(
        'title' => 'List links',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      );
      $items['menu-test/hidden/menu/manage/%menu/add'] = array(
        'title' => 'Add link',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_ACTION,
      );
      $items['menu-test/hidden/menu/manage/%menu/edit'] = array(
        'title' => 'Edit menu',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      );
      $items['menu-test/hidden/menu/manage/%menu/delete'] = array(
        'title' => 'Delete menu',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
    
      // Hidden tests; two dynamic arguments.
      $items['menu-test/hidden/block'] = array(
        'title' => 'Blocks',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
      $items['menu-test/hidden/block/list'] = array(
        'title' => 'List',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      $items['menu-test/hidden/block/add'] = array(
        'title' => 'Add block',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_ACTION,
      );
      $items['menu-test/hidden/block/manage/%/%'] = array(
        'title' => 'Configure block',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
      );
      $items['menu-test/hidden/block/manage/%/%/configure'] = array(
        'title' => 'Configure block',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'context' => MENU_CONTEXT_INLINE,
      );
      $items['menu-test/hidden/block/manage/%/%/delete'] = array(
        'title' => 'Delete block',
        'page callback' => 'test_page_test_page',
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_NONE,
      );
    
      // Breadcrumbs tests.
      // @see \Drupal\system\Tests\Menu\BreadcrumbTest
      $base = array(
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
      // Local tasks: Second level below default local task.
      $items['menu-test/breadcrumb/tasks'] = array(
        'title' => 'Breadcrumbs test: Local tasks',
      ) + $base;
      $items['menu-test/breadcrumb/tasks/first'] = array(
        'title' => 'First',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      ) + $base;
      $items['menu-test/breadcrumb/tasks/second'] = array(
        'title' => 'Second',
        'type' => MENU_LOCAL_TASK,
      ) + $base;
      $items['menu-test/breadcrumb/tasks/first/first'] = array(
        'title' => 'First first',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      ) + $base;
      $items['menu-test/breadcrumb/tasks/first/second'] = array(
        'title' => 'First second',
        'type' => MENU_LOCAL_TASK,
      ) + $base;
      $items['menu-test/breadcrumb/tasks/second/first'] = array(
        'title' => 'Second first',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      ) + $base;
      $items['menu-test/breadcrumb/tasks/second/second'] = array(
        'title' => 'Second second',
        'type' => MENU_LOCAL_TASK,
      ) + $base;
    
      // Menu local tasks tests.
      // @see \Drupal\system\Tests\Menu\TrailTest
      $items['menu-test/tasks'] = array(
        'title' => 'Local tasks',
      ) + $base;
      $items['menu-test/tasks/empty'] = array(
        'title' => 'Empty',
      ) + $base;
      $items['menu-test/tasks/default'] = array(
        'title' => 'Default only',
      ) + $base;
      $items['menu-test/tasks/default/view'] = array(
        'title' => 'View',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      ) + $base;
      $items['menu-test/tasks/tasks'] = array(
        'title' => 'With tasks',
      ) + $base;
      $items['menu-test/tasks/tasks/view'] = array(
        'title' => 'View',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      ) + $base;
      $items['menu-test/tasks/tasks/edit'] = array(
        'title' => 'Edit',
        'type' => MENU_LOCAL_TASK,
      ) + $base;
      $items['menu-test/tasks/tasks/settings'] = array(
        'title' => 'Settings',
        'type' => MENU_LOCAL_TASK,
        'weight' => 100,
      ) + $base;
    
      // Menu trail tests.
      // @see MenuTrailTestCase
      $items['menu-test/menu-trail'] = array(
        'title' => 'Menu trail - Case 1',
        'page callback' => 'menu_test_menu_trail_callback',
        'access arguments' => array('access content'),
      );
      $items['admin/config/development/menu-trail'] = array(
        'title' => 'Menu trail - Case 2',
        'description' => 'Tests menu_tree_set_path()',
        'page callback' => 'menu_test_menu_trail_callback',
        'access arguments' => array('access administration pages'),
      );
      $items['menu-test/custom-403-page'] = array(
        'title' => 'Custom 403 page',
        'page callback' => 'menu_test_custom_403_404_callback',
        'access arguments' => array('access content'),
      );
      $items['menu-test/custom-404-page'] = array(
        'title' => 'Custom 404 page',
        'page callback' => 'menu_test_custom_403_404_callback',
        'access arguments' => array('access content'),
      );
    
      // File inheritance tests. This menu item should inherit the page callback
      // system_admin_menu_block_page() and therefore render its children as links
      // on the page.
      $items['admin/config/development/file-inheritance'] = array(
        'title' => 'File inheritance',
        'description' => 'Test file inheritance',
        'access arguments' => array('access content'),
      );
      $items['admin/config/development/file-inheritance/inherit'] = array(
        'title' => 'Inherit',
        'description' => 'File inheritance test description',
        'page callback' => 'menu_test_callback',
        'access arguments' => array('access content'),
      );
    
      // Test the access key with a function callback.
      $items['menu_login_callback'] = array(
        'title' => 'Used as a login path',
        'page callback' => 'menu_login_callback',
        'access callback' => TRUE,
      );
    
      // Test the access key.
      $items['menu-title-test/case1'] = array(
       'title' => 'Example title - Case 1',
       'access callback' => TRUE,
       'page callback' => 'menu_test_callback',
      );
      $items['menu-title-test/case2'] = array(
       'title' => 'Example @sub1 - Case @op2',
       // If '2' is not in quotes, the argument becomes arg(2).
       'title arguments' => array('@sub1' => 'title', '@op2' => '2'),
       'access callback' => TRUE,
       'page callback' => 'menu_test_callback',
      );
      $items['menu-title-test/case3'] = array(
       'title' => 'Example title',
       'title callback' => 'menu_test_title_callback',
       'access callback' => TRUE,
       'page callback' => 'menu_test_callback',
      );
      $items['menu-title-test/case4'] = array(
       // Title gets completely ignored. Good thing, too.
       'title' => 'Bike sheds full of blue smurfs',
       'title callback' => 'menu_test_title_callback',
       // If '4' is not in quotes, the argument becomes arg(4).
       'title arguments' => array('Example title', '4'),
       'access callback' => TRUE,
       'page callback' => 'menu_test_callback',
      );
    
      // Load arguments inheritance test.
      $items['menu-test/arguments/%menu_test_argument/%'] = array(
        'title' => 'Load arguments inheritance test',
        'load arguments' => array(3),
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
      $items['menu-test/arguments/%menu_test_argument/%/default'] = array(
        'title' => 'Default local task',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      $items['menu-test/arguments/%menu_test_argument/%/task'] = array(
        'title' => 'Local task',
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
      );
      // For this path, load arguments should be inherited for the first loader only.
      $items['menu-test/arguments/%menu_test_argument/%menu_test_other_argument/common-loader'] = array(
        'title' => 'Local task',
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
      );
      // For these paths, no load arguments should be inherited.
      // Not on the same position.
      $items['menu-test/arguments/%/%menu_test_argument/different-loaders-1'] = array(
        'title' => 'An item not sharing the same loader',
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
      // Not the same loader.
      $items['menu-test/arguments/%menu_test_other_argument/%/different-loaders-2'] = array(
        'title' => 'An item not sharing the same loader',
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
      // Not the same loader.
      $items['menu-test/arguments/%/%/different-loaders-3'] = array(
        'title' => 'An item not sharing the same loader',
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
      // Explicit load arguments should not be overridden (even if empty).
      $items['menu-test/arguments/%menu_test_argument/%/explicit-arguments'] = array(
        'title' => 'An item defining explicit load arguments',
        'load arguments' => array(),
        'page callback' => 'menu_test_callback',
        'access callback' => TRUE,
      );
    
      // Parent page for controller-based local tasks.
      $items['foo/%'] = array(
        'title' => 'Controller-based local tasks',
        'route_name' => 'menu_router_test1',
      );
      // Controller-based local task.
      $items['foo/%/a'] = array(
        'title' => 'Local task A',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      // Controller-based local task.
      $items['foo/%/b'] = array(
        'title' => 'Local task B',
        'route_name' => 'menu_router_test2',
        'type' => MENU_LOCAL_TASK,
      );
      $items['foo/%/c'] = array(
        'title' => 'Local task C',
        'route_name' => 'menu_router_test3',
        'type' => MENU_LOCAL_TASK,
      );
    
      $items['menu-test-local-action'] = array(
        'title' => 'Local action parent',
        'route_name' => 'menu_test_local_action1',
      );
    
      $items['menu-test-local-action/hook_menu'] = array(
        'title' => 'My hook_menu action',
        'route_name' => 'menu_test_local_action2',
        'weight' => -10,
        'type' => MENU_LOCAL_ACTION,
      );
    
      $items['menu-test-local-action/dynamic-title'] = array(
        'title' => 'My dynamic title action',
        'title callback' => 'menu_test_local_action_dynamic_title',
        'title arguments' => array(1),
        'route_name' => 'menu_test_local_action4',
        'weight' => -10,
        'type' => MENU_LOCAL_ACTION,
      );
    
      return $items;
    }
    
    /**
     * Title callback: Set a dynamic title for a local action.
     */
    function menu_test_local_action_dynamic_title($arg) {
      return t('My @arg action', array('@arg' => $arg));
    }
    
    /**
     * Implements hook_menu_local_tasks().
     *
     * If the menu_test.settings configuration 'tasks.add' has been set, adds
     * several local tasks to menu-test/tasks.
     */
    function menu_test_menu_local_tasks(&$data, $router_item, $root_path) {
      if (!config('menu_test.settings')->get('tasks.add')) {
        return;
      }
      if (strpos($router_item['tab_root'], 'menu-test/tasks/') === 0) {
        $data['tabs'][0]['foo'] = array(
          '#theme' => 'menu_local_task',
          '#link' => array(
            'title' => 'Task 1',
            'href' => 'task/foo',
          ),
          '#weight' => 10,
        );
        $data['tabs'][0]['bar'] = array(
          '#theme' => 'menu_local_task',
          '#link' => array(
            'title' => 'Task 2',
            'href' => 'task/bar',
          ),
          '#weight' => 20,
        );
      }
    }
    
    /**
     * Implements hook_menu_local_tasks_alter().
     *
     * If the menu_test.settings configuration 'tasks.alter' has been set, adds
     * several local tasks to menu-test/tasks.
     */
    function menu_test_menu_local_tasks_alter(&$data, $router_item, $root_path) {
      if (!config('menu_test.settings')->get('tasks.alter')) {
        return;
      }
      if (strpos($router_item['tab_root'], 'menu-test/tasks/') === 0) {
        // Rename the default local task from 'View' to 'Show'.
        // $data['tabs'] is expected to be keyed by link hrefs.
        // The default local task always links to its parent path, which means that
        // if the tab root path appears as key in $data['tabs'], then that key is
        // the default local task.
        $key = $router_item['tab_root'];
        if (isset($data['tabs'][0][$key])) {
          $data['tabs'][0][$key]['#link']['title'] = 'Show it';
        }
        // Rename the 'foo' task to "Advanced settings" and put it last.
        $data['tabs'][0]['foo']['#link']['title'] = 'Advanced settings';
        $data['tabs'][0]['foo']['#weight'] = 110;
      }
    }
    
    /**
     * Argument callback: Loads an argument using a function for hook_menu().
     *
     * @param string $arg1
     *   A parameter passed in via the URL.
     *
     * @return false
     *   Always return NULL.
     *
     * @see menu_test_menu();
     */
    function menu_test_argument_load($arg1) {
      return NULL;
    }
    
    /**
     * Argument callback: Loads an argument using a function for hook_menu().
     *
     * @param string $arg1
     *   A parameter passed in via the URL.
     *
     * @return false
     *   Always return NULL.
     *
     * @see menu_test_menu();
     */
    function menu_test_other_argument_load($arg1) {
      return NULL;
    }
    
    /**
     * Page callback: Provides a dummy function which can be used as a placeholder.
     *
     * @return string
     *   A string that can be used for comparison.
     *
     * @see menu_test_menu().
     */
    function menu_test_callback() {
      return 'This is menu_test_callback().';
    }
    
    /**
     * Page callback: Tests menu_test_menu_tree_set_path().
     *
     * Retrieves the current menu path and if the menu path is not empty updates
     * the menu path that is used to determine the active menu trail.
     *
     * @return string
     *   A string that can be used for comparison.
     *
     * @see menu_test_menu().
     */
    function menu_test_menu_trail_callback() {
      $menu_path = Drupal::state()->get('menu_test.menu_tree_set_path') ?: array();
      if (!empty($menu_path)) {
        menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
      }
      return 'This is menu_test_menu_trail_callback().';
    }
    
    /**
     * Page callback: Sets the active menu trail for our custom 403 and 404 pages.
     *
     * @return string
     *   A text string that can be used for comparison.
     *
     * @see menu_test_menu().
     */
    function menu_test_custom_403_404_callback() {
      // When requested by one of the TrailTest tests, record the final
      // active trail now that the user has been redirected to the custom 403 or
      // 404 page.
      if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) {
        Drupal::state()->set('menu_test.active_trail_final', menu_get_active_trail());
      }
    
      return 'This is menu_test_custom_403_404_callback().';
    }
    
    /**
     * Page callback: Tests the theme callback functionality.
     *
     * @param bool $inherited
     *   (optional) TRUE when the requested page is intended to inherit
     *   the theme of its parent.
     *
     * @return string
     *   A string describing the requested custom theme and actual theme being used
     *   for the current page request.
     *
     * @see menu_test_menu().
     */
    function menu_test_theme_page_callback($inherited = FALSE) {
      global $theme_key;
      // Initialize the theme system so that $theme_key will be populated.
      drupal_theme_initialize();
      // Now check both the requested custom theme and the actual theme being used.
      $custom_theme = menu_get_custom_theme();
      $requested_theme = empty($custom_theme) ? 'NONE' : $custom_theme;
      $output = "Custom theme: $requested_theme. Actual theme: $theme_key.";
      if ($inherited) {
        $output .= ' Theme callback inheritance is being tested.';
      }
      return $output;
    }
    
    /**
     * Theme callback: Tests the theme callback functionality.
     *
     * Retrieves the theme key of the theme to use for the current request based on
     * the theme name provided in the URL.
     *
     * @param string $argument
     *   The argument passed in from the URL.
     *
     * @return string
     *   The name of the custom theme to request for the current page.
     *
     * @see menu_test_menu().
     */
    function menu_test_theme_callback($argument) {
      // Test using the variable administrative theme.
      if ($argument == 'use-admin-theme') {
        return config('system.theme')->get('admin');
      }
      // Test using a theme that exists, but may or may not be enabled.
      elseif ($argument == 'use-stark-theme') {
        return 'stark';
      }
      // Test using a theme that does not exist.
      elseif ($argument == 'use-fake-theme') {
        return 'fake_theme';
      }
      // For any other value of the URL argument, do not return anything. This
      // allows us to test that returning nothing from a theme callback function
      // causes the page to correctly fall back on using the main site theme.
    }
    
    /**
     * Implements hook_custom_theme().
     *
     * If an appropriate variable has been set in the database, request the theme
     * that is stored there. Otherwise, do not attempt to dynamically set the theme.
     */
    function menu_test_custom_theme() {
      // When requested by one of the MenuTrailTestCase tests, record the initial
      // active trail during Drupal's bootstrap (before the user is redirected to a
      // custom 403 or 404 page). See menu_test_custom_403_404_callback().
      if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) {
        Drupal::state()->set('menu_test.active_trail_initial', menu_get_active_trail());
      }
      if ($theme = Drupal::state()->get('menu_test.hook_custom_theme_name') ?: FALSE) {
        return $theme;
      }
    }
    
    /**
     * Sets a static variable for the testMenuName() test.
     *
     * Used to change the menu_name parameter of a menu.
     *
     * @param string $new_name
     *   (optional) If set, will change the $menu_name value.
     *
     * @return string
     *   The $menu_name value to use.
     */
    function menu_test_menu_name($new_name = '') {
      static $menu_name = 'original';
      if ($new_name) {
        $menu_name = $new_name;
      }
      return $menu_name;
    }
    
    /**
     * Implements hook_menu_link_insert().
     */
    function menu_test_menu_link_insert(MenuLink $item) {
      menu_test_static_variable('insert');
    }
    
    /**
     * Implements hook_menu_link_update().
     */
    function menu_test_menu_link_update(MenuLink $item) {
      menu_test_static_variable('update');
    }
    
    /**
     * Implements hook_menu_link_delete().
     */
    function menu_test_menu_link_delete(MenuLink $item) {
      menu_test_static_variable('delete');
    }
    
    /**
     * Sets a static variable for testing hook results.
     *
     * @param null|string $value
     *   (optional) The value to set or NULL to return the current value.
     *
     * @return null|string
     *   A text string for comparison to test assertions.
     */
    function menu_test_static_variable($value = NULL) {
      static $variable;
      if (!empty($value)) {
        $variable = $value;
      }
      return $variable;
    }
    
    /**
     * Page callback: Provides a login path.
     *
     * @return string
     *   A text string that can be used for comparison.
     *
     * @see menu_test_menu().
     */
    function menu_login_callback() {
      return 'This is menu_login_callback().';
    }
    
    /**
     * Title callback: Concatenates the title and case number.
     *
     * @param string $title
     *   Title string.
     * @param int $case_number
     *   (optional) The current case number which it tests (defaults to 3).
     *
     * @return string
     *   A string containing the title and case number.
     *
     * @see menu_test_menu().
     */
    function menu_test_title_callback($title, $case_number = 3) {
      return t($title) . ' - Case ' . $case_number;
    }