You are here

function farm_asset_menu in farmOS 7

Implements hook_menu().

File

modules/farm/farm_asset/farm_asset.module, line 75
Farm asset - A farm asset entity type.

Code

function farm_asset_menu() {
  $items = array();
  $items['farm/asset/add'] = array(
    'title' => 'Add asset',
    'page callback' => 'farm_asset_add_types_page',
    'access callback' => 'farm_asset_add_access',
    'file' => 'farm_asset.pages.inc',
  );
  foreach (farm_asset_types() as $type => $info) {
    $items['farm/asset/add/' . $type] = array(
      'title' => 'Add ' . $info->label,
      'page callback' => 'farm_asset_add',
      'page arguments' => array(
        3,
      ),
      'access callback' => 'farm_asset_access',
      'access arguments' => array(
        'create',
        3,
      ),
      'file' => 'farm_asset.pages.inc',
    );
  }
  $farm_asset_uri = 'farm/asset/%farm_asset';
  $farm_asset_uri_argument_position = 2;
  $items[$farm_asset_uri] = array(
    'title callback' => 'entity_label',
    'title arguments' => array(
      'farm_asset',
      $farm_asset_uri_argument_position,
    ),
    'page callback' => 'farm_asset_view',
    'page arguments' => array(
      $farm_asset_uri_argument_position,
    ),
    'access callback' => 'farm_asset_access',
    'access arguments' => array(
      'view',
      $farm_asset_uri_argument_position,
    ),
    'file' => 'farm_asset.pages.inc',
  );
  $items[$farm_asset_uri . '/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items[$farm_asset_uri . '/delete'] = array(
    'title' => 'Delete asset',
    'title callback' => 'farm_asset_label',
    'title arguments' => array(
      $farm_asset_uri_argument_position,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'farm_asset_delete_form',
      $farm_asset_uri_argument_position,
    ),
    'access callback' => 'farm_asset_access',
    'access arguments' => array(
      'update',
      $farm_asset_uri_argument_position,
    ),
    'file' => 'farm_asset.pages.inc',
  );
  $items[$farm_asset_uri . '/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'farm_asset_form',
      $farm_asset_uri_argument_position,
    ),
    'access callback' => 'farm_asset_access',
    'access arguments' => array(
      'update',
      $farm_asset_uri_argument_position,
    ),
    'file' => 'farm_asset.pages.inc',
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );

  // Asset type delete form.
  $items['admin/config/farm/asset-types/%farm_asset_type/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'farm_asset_type_form_delete_confirm',
      4,
    ),
    'access arguments' => array(
      'administer farm_asset types',
    ),
    'weight' => 1,
    'type' => MENU_NORMAL_ITEM,
    'file' => 'farm_asset.admin.inc',
  );

  // Asset autocomplete path.
  $items['farm_asset/autocomplete/%/%'] = array(
    'title' => 'Autocomplete for farm assets',
    'page callback' => 'farm_asset_autocomplete',
    'page arguments' => array(
      2,
      3,
    ),
    'access callback' => 'farm_asset_autocomplete_access',
    'access arguments' => array(
      2,
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}