function entityconnect_entityconnect_edit_info in Entity connect 7.2
Same name and namespace in other branches
- 8.2 entityconnect.module \entityconnect_entityconnect_edit_info()
Implements hook_entityconnect_edit_info().
File
- includes/
entityconnect.menu.inc, line 233 - Handles all entityconnect menu item page callbacks.
Code
function entityconnect_entityconnect_edit_info($cache_id, $entity_type, $target_id) {
if (!isset($entity_type)) {
throw new \Exception(t('Entity type can not be empty'));
}
if (!isset($target_id)) {
throw new \Exception(t('Target_id can not be empty'));
}
switch ($entity_type) {
case 'node':
if (is_array($target_id)) {
$info = entity_load($entity_type, $target_id);
foreach ($info as $key => $value) {
$content[$key] = array(
'label' => $value->title,
'href' => 'node/' . $value->nid . '/edit',
'description' => '',
);
}
}
else {
$content[$entity_type]['href'] = "node/{$target_id}/edit";
}
break;
case 'user':
if (is_array($target_id)) {
$info = entity_load($entity_type, $target_id);
foreach ($info as $key => $value) {
$content[$key] = array(
'label' => $value->name,
'href' => 'user/' . $value->uid . '/edit',
'description' => '',
);
}
}
else {
$content[$entity_type]['href'] = "user/{$target_id}/edit";
}
break;
case 'taxonomy_term':
if (is_array($target_id)) {
$info = entity_load($entity_type, $target_id);
foreach ($info as $key => $value) {
$content[$key] = array(
'label' => $value->name,
'href' => 'taxonomy/term/' . $value->tid . '/edit',
'description' => '',
);
}
}
else {
$content[$entity_type]['href'] = "taxonomy/term/{$target_id}/edit";
}
break;
case 'taxonomy_vocabulary':
if (is_array($target_id)) {
$info = entity_load($entity_type, $target_id);
foreach ($info as $key => $value) {
$content[$key] = array(
'label' => $value->name,
'href' => 'admin/structure/taxonomy/' . $value->name . '/edit',
'description' => '',
);
}
}
else {
$info = entity_load_single($entity_type, $target_id);
$content[$entity_type]['href'] = "admin/structure/taxonomy/{$info->name}/edit";
}
break;
default:
break;
}
if (isset($theme_callback)) {
return array(
'content' => $content,
'theme_callback' => $theme_callback,
);
}
else {
return array(
'content' => $content,
);
}
}