function entityconnect_eck_entityconnect_edit_info in Entity connect 7.2
Implements hook_entityconnect_edit_info().
File
- modules/
entityconnect_eck/ entityconnect_eck.module, line 160
Code
function entityconnect_eck_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'));
}
$entity_info = entity_get_info($entity_type);
if (isset($entity_info['module']) && $entity_info['module'] == 'eck') {
if (is_array($target_id)) {
$eck_entities = entity_load($entity_type, $target_id);
foreach ($eck_entities as $key => $eck_entity) {
$crud_edit_path = preg_replace('/\\%/', $key, $entity_info['bundles'][$eck_entity->type]['crud']['edit']['path']);
$content[$key] = array(
'label' => $eck_entity->title,
'href' => $crud_edit_path,
'description' => '',
);
}
}
else {
$eck_entity = entity_load_single($entity_type, $target_id);
$crud_edit_path = preg_replace('/\\%/', $target_id, $entity_info['bundles'][$eck_entity->type]['crud']['edit']['path']);
$content[$entity_type]['href'] = $crud_edit_path;
}
return array(
'content' => $content,
);
}
}