function entityconnect_add in Entity connect 7.2
Same name and namespace in other branches
- 7 includes/entityconnect.menu.inc \entityconnect_add()
Page callback: Load cached form info.
This page will load the cached form info, and display links to each of the entityreference types. If there is only one it will redirect to that page.
This is mostly a copy and hack up of the node add page.
This page is directed to from the entityconnect_add_button_submit.
1 string reference to 'entityconnect_add'
- entityconnect_menu in ./
entityconnect.module - Implements hook_menu().
File
- includes/
entityconnect.menu.inc, line 41 - Handles all entityconnect menu item page callbacks.
Code
function entityconnect_add($cache_id) {
$cache = entityconnect_cache_get($cache_id);
$entity_type = $cache->data['target_entity_type'];
$acceptable_types = $cache->data['acceptable_types'];
$add_info = module_invoke_all('entityconnect_add_info', $cache_id, $entity_type, $acceptable_types);
// Merge in default values.
foreach ($add_info as $name => $data) {
$add_info += array(
'content' => array(
'href' => '',
'label' => '',
'description' => '',
),
'theme_callback' => 'entityconnect_entity_add_list',
);
}
$context = array(
'cache_id' => $cache_id,
'entity_type' => $entity_type,
'acceptable_tpes' => $acceptable_types,
);
drupal_alter('entityconnect_add_info', $add_info, $context);
if (isset($add_info)) {
$content = $add_info['content'];
$theme = $add_info['theme_callback'];
}
// If we have only one content-type defined,
// go directly to the node form.
if (count($content) == 1) {
$item = array_pop($content);
// Cast every item as array.
// That allow both object or array to be treated the same way.
$item = (array) $item;
drupal_goto($item['href']);
}
$output = theme($theme, array(
'cache id' => $cache_id,
'items' => $content,
));
$output .= l(t('Cancel'), "admin/entityconnect/return/{$cache_id}");
return $output;
}