You are here

function eck__bundle__menu in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.bundle.inc \eck__bundle__menu()
  2. 7 eck.bundle.inc \eck__bundle__menu()

This function creates the menu items relevant to bundle administration.

Parameters

/EntityType $entity_type: As returned by eck__entity_type__load().

Return value

array A menu item array.

See also

eck_menu()

1 call to eck__bundle__menu()
eck__entity_type__menu in ./eck.entity_type.inc
Passthrough from hook_menu().

File

./eck.bundle.inc, line 20

Code

function eck__bundle__menu($entity_type) {

  // Create the menus relavant to types.
  $path = eck__entity_type__path();
  $menu = array();

  // Dummy menu items so that entity translation will not complain about there
  // not being a default.
  // @todo: Remove these dummy items once issue https://drupal.org/node/2273189
  // is resolved.
  $menu["{$entity_type->name}/%"] = array(
    'page callback' => FALSE,
    'page arguments' => array(),
    'access callback' => FALSE,
    'access arguments' => array(),
  );
  $menu["{$entity_type->name}/%/edit"] = array(
    'page callback' => FALSE,
    'page arguments' => array(),
    'access callback' => FALSE,
    'access arguments' => array(),
  );

  // DELETE Entity Types.
  $menu["{$path}/{$entity_type->name}/delete"] = array(
    'title' => "Delete",
    'description' => "Delete the '{$entity_type->label}' Entity Type",
    // "eck__entity_type__delete",
    'page callback' => "drupal_get_form",
    'page arguments' => array(
      "eck__entity_type__delete_form",
      $entity_type->name,
    ),
    'access callback' => 'eck__multiple_access_check',
    'access arguments' => array(
      array(
        'eck administer entity types',
        'eck delete entity types',
      ),
    ),
    'file' => 'eck.entity_type.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 3,
  );

  // MANAGE Entity Type Properties.
  $menu["{$path}/{$entity_type->name}/properties"] = array(
    'title' => "Manage properties",
    'description' => "Manage the properties of the {$entity_type->label} entity type",
    // "eck__entity_type__delete",
    'page callback' => "drupal_get_form",
    'page arguments' => array(
      "eck__properties__form",
      $entity_type->name,
    ),
    'access callback' => 'eck__multiple_access_check',
    'access arguments' => array(
      array(
        'eck administer entity types',
        "manage {$entity_type->name} properties",
      ),
    ),
    'file' => 'eck.properties.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 4,
  );

  // LIST Bundles.
  $menu["{$path}/{$entity_type->name}"] = array(
    'title' => "{$entity_type->label}",
    'description' => "View all the bundles for '{$entity_type->label}'",
    'page callback' => "eck__bundle__list",
    'page arguments' => array(
      3,
    ),
    'access callback' => 'eck__multiple_access_check',
    'access arguments' => array(
      array(
        'eck administer bundles',
        'eck list bundles',
        "eck administer {$entity_type->name} bundles",
        "eck list {$entity_type->name} bundles",
      ),
    ),
    'file' => 'eck.bundle.inc',
  );
  $menu["{$path}/{$entity_type->name}/list"] = array(
    'title' => 'Bundle List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 100,
  );

  // EDIT Entity Types.
  $menu["{$path}/{$entity_type->name}/edit"] = array(
    'title' => "Edit",
    'description' => "Edit the '{$entity_type->label}' entity type",
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      "eck__entity_type__form",
      $entity_type->name,
    ),
    'access callback' => 'eck__multiple_access_check',
    'access arguments' => array(
      array(
        'eck administer entity types',
        'eck edit entity types',
      ),
    ),
    'file' => 'eck.entity_type.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );

  // ADD Bundles.
  $menu["{$path}/{$entity_type->name}/add"] = array(
    'title' => "Add bundle ",
    'description' => "Add a(n) new '{$entity_type->label} Bundle'",
    'page callback' => "drupal_get_form",
    'page arguments' => array(
      'eck__bundle__add',
      3,
    ),
    'access callback' => 'eck__multiple_access_check',
    'access arguments' => array(
      array(
        'eck administer bundles',
        'eck add bundles',
        "eck administer {$entity_type->name} bundles",
        "eck add {$entity_type->name} bundles",
      ),
    ),
    'type' => MENU_LOCAL_ACTION,
    'weight' => 0,
    'file' => 'eck.bundle.inc',
  );
  module_load_include('inc', 'eck', 'eck.entity');
  foreach (Bundle::loadByEntityType($entity_type) as $bundle) {
    $menu = array_merge($menu, eck__entity__menu($entity_type, $bundle));
  }
  return $menu;
}