function xmlsitemap_menu_entity_info_alter in XML sitemap 7.2
Implements hook_entity_info_alter().
Adds support for the menu link entity if it doesn't already exist.
File
- xmlsitemap_menu/
xmlsitemap_menu.module, line 13 - Main file for XML sitemap menu.
Code
function xmlsitemap_menu_entity_info_alter(&$info) {
if (!isset($info['menu_link'])) {
$info['menu_link'] = array(
'label' => t('Menu link'),
'controller class' => 'DrupalDefaultEntityController',
'base table' => 'menu_links',
'uri callback' => 'xmlsitemap_menu_menu_link_uri',
'fieldable' => FALSE,
'static cache' => TRUE,
'field cache' => TRUE,
'entity keys' => array(
'id' => 'mlid',
'bundle' => 'menu_name',
'label' => 'link_title',
'revision' => '',
),
'load hook' => NULL,
'view modes' => array(),
'translation' => array(),
'schema_fields_sql' => array(
'base table' => drupal_schema_fields_sql('menu_links'),
),
'xmlsitemap' => array(
'process callback' => 'xmlsitemap_menu_xmlsitemap_process_menu_links',
),
'bundle label' => t('Menu'),
'token type' => 'menu_link',
);
foreach (menu_get_menus() as $type => $name) {
$info['menu_link']['bundles'][$type] = array(
'label' => $name,
'admin' => array(
'path' => 'admin/structure/menu/manage/%menu/edit',
'bundle argument' => 4,
'real path' => 'admin/structure/menu/manage/' . $type . '/edit',
'access arguments' => array(
'administer menus',
),
),
);
}
}
else {
// If the entity type already exists ensure the xmlsitemap is added.
$info['menu_link'] += array(
'uri callback' => 'xmlsitemap_menu_menu_link_uri',
'xmlsitemap' => array(
'process callback' => 'xmlsitemap_menu_xmlsitemap_process_menu_links',
),
);
if (!isset($info['menu_link']['bundle label'])) {
$info['menu_link']['bundle label'] = t('Menu');
}
}
}