function entityconnect_edit in Entity connect 7.2
Same name and namespace in other branches
- 7 includes/entityconnect.menu.inc \entityconnect_edit()
Page callback: Redirect to edit form.
We use this to redirect to a edit form but pass the build_cache_id.
1 string reference to 'entityconnect_edit'
- entityconnect_menu in ./
entityconnect.module - Implements hook_menu().
File
- includes/
entityconnect.menu.inc, line 178 - Handles all entityconnect menu item page callbacks.
Code
function entityconnect_edit($cache_id) {
$cache = entityconnect_cache_get($cache_id);
$entity_type = $cache->data['target_entity_type'];
$target_id = $cache->data['target_id'];
$edit_info = module_invoke_all('entityconnect_edit_info', $cache_id, $entity_type, $target_id);
// Merge in default values.
foreach ($edit_info as $name => $data) {
$edit_info += array(
'content' => array(
'href' => '',
'label' => '',
'description' => '',
),
'theme_callback' => 'entityconnect_entity_add_list',
);
}
$context = array(
'cache_id' => $cache_id,
'entity_type' => $entity_type,
'target_id' => $target_id,
);
drupal_alter('entityconnect_edit_info', $edit_info, $context);
if (isset($edit_info)) {
$content = $edit_info['content'];
$theme = $edit_info['theme_callback'];
}
if (count($content) == 1) {
$item = array_pop($content);
if (is_array($item['href'])) {
$href = array_shift($item['href']);
}
else {
$href = $item['href'];
}
drupal_goto($href, array(
'query' => array(
"build_cache_id" => $cache_id,
"child" => TRUE,
),
));
}
$output = theme($theme, array(
'cache id' => $cache_id,
'items' => $content,
));
$output .= l(t('Cancel'), "admin/entityconnect/return/{$cache_id}");
return $output;
}