You are here

function flexiform_menu in Flexiform 7

Implements hook_menu()

We want to add a manage form fields tab and a manage form entities tab for each flexiform

File

./flexiform.module, line 30
Module for the Flexiform system.

Code

function flexiform_menu() {
  $items = array();
  $displays = flexiform_display_info();
  $hook_menu_displays = array();
  foreach ($displays as $name => $info) {
    if (method_exists($info['class'], 'hook_menu')) {
      $hook_menu_displays[] = $name;
    }
  }
  if ($hook_menu_displays) {

    /** @var \FlexiformController $controller */
    $controller = entity_get_controller('flexiform');
    foreach ($controller
      ->loadWithDisplay($hook_menu_displays) as $form) {
      foreach ($hook_menu_displays as $name) {
        if (($display = $form
          ->getDisplay($name)) && $display
          ->isEnabled()) {
          $items += $display
            ->hook_menu();
        }
      }
    }
  }

  // Entityreference autocomplete flexiform.
  if (module_exists('entityreference')) {
    $items['flexiform/entityreference/autocomplete/single/%flexiform/%'] = array(
      'title' => 'Flexiform Entity Reference Autocomplete',
      'page callback' => 'flexiform_entityreference_autocomplete_callback',
      'page arguments' => array(
        3,
        4,
        5,
      ),
      'access callback' => 'flexiform_entityreference_autocomplete_access_callback',
      'access arguments' => array(
        3,
        4,
        5,
      ),
      'file' => 'flexiform.entityreference.inc',
      'type' => MENU_CALLBACK,
    );
    $items['flexiform/entityreference/autocomplete/tags/%flexiform/%'] = array(
      'title' => 'Flexiform Entity Reference Autocomplete',
      'page callback' => 'flexiform_entityreference_autocomplete_callback',
      'page arguments' => array(
        3,
        4,
        5,
      ),
      'access callback' => 'flexiform_entityreference_autocomplete_access_callback',
      'access arguments' => array(
        3,
        4,
        5,
      ),
      'file' => 'flexiform.entityreference.inc',
      'type' => MENU_CALLBACK,
    );
  }
  return $items;
}