You are here

function _bundle_copy_bundle_info in Bundle Copy 7

Same name and namespace in other branches
  1. 7.2 bundle_copy.module \_bundle_copy_bundle_info()

Return bundles for a certain entity type.

Parameters

$entity_type: The name of the entity type.

$table_select: Whether we're returning for the table select or not.

2 calls to _bundle_copy_bundle_info()
bundle_copy_export in ./bundle_copy.module
Menu callback: present the export page.
bundle_copy_import_submit in ./bundle_copy.module
Submit callback: import data.

File

./bundle_copy.module, line 429
Bundle copy.

Code

function _bundle_copy_bundle_info($entity_type, $table_select = FALSE) {
  static $bundles = array();
  if (!isset($bundles[$entity_type])) {
    $bundles[$entity_type] = array();
    $entity_info = entity_get_info($entity_type);
    $entity_bundles = $entity_info['bundles'];
    ksort($entity_bundles);
    foreach ($entity_bundles as $key => $info) {
      $label = isset($info['label']) ? $info['label'] : drupal_ucfirst(str_replace('_', ' ', $key));
      if ($table_select) {
        $bundles[$entity_type][$key]['label'] = $label;
      }
      else {
        $bundles[$entity_type][$key] = $label;
      }
    }
  }
  return $bundles[$entity_type];
}