You are here

function entityconnect_bean_entityconnect_edit_info in Entity connect 7.2

Implements hook_entityconnect_edit_info().

File

modules/entityconnect_bean/entityconnect_bean.module, line 140

Code

function entityconnect_bean_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'] == 'bean') {
    if (is_array($target_id)) {
      $info = entity_load($entity_type, $target_id);
      foreach ($info as $key => $value) {
        $content[$key] = array(
          'label' => $value->label,
          'href' => 'block/' . $value->delta . '/edit',
          'description' => '',
        );
      }
    }
    else {
      $bean_entity = entity_load_single($entity_type, $target_id);
      $content[$entity_type]['href'] = "block/{$bean_entity->delta}/edit";
    }
    return array(
      'content' => $content,
    );
  }
}