You are here

function entityconnect_bean_entityconnect_add_info in Entity connect 7.2

Implements hook_entityconnect_add_info().

File

modules/entityconnect_bean/entityconnect_bean.module, line 101

Code

function entityconnect_bean_entityconnect_add_info($cache_id, $entity_type, $acceptable_types) {
  if (!isset($entity_type)) {
    throw new \Exception(t('Entity type can not be empty'));
  }
  $entity_info = entity_get_info($entity_type);
  if (isset($entity_info['module']) && $entity_info['module'] == 'bean') {
    if (count($acceptable_types) > 0) {
      foreach (bean_admin_ui_get_types() as $key => $item) {
        if (isset($acceptable_types[$key]) && $acceptable_types[$key]) {
          $type = str_replace("_", '-', $key);
          $content[$key] = array(
            'href' => "block/add/{$type}/{$cache_id}",
            'label' => $item->label,
            'description' => $item->description,
          );
        }
      }
    }
    else {
      foreach (bean_admin_ui_get_types() as $key => $item) {
        $type = str_replace("_", '-', $key);
        $content[$key] = array(
          'href' => "block/add/{$type}/{$cache_id}",
          'label' => $item->label,
          'description' => $item->description,
        );
      }
    }
    return array(
      'content' => $content,
    );
  }
}