function field_test_create_bundle

Creates a new bundle for test_entity entities.

Parameters

$bundle: The machine-readable name of the bundle.

$text: The human-readable name of the bundle. If none is provided, the machine name will be used.

7 calls to field_test_create_bundle()

File

drupal/core/modules/field/tests/modules/field_test/field_test.entity.inc, line 66
Defines an entity type.

Code

function field_test_create_bundle($bundle, $text = NULL) {
  $bundles = state()
    ->get('field_test.bundles') ?: array(
    'test_bundle' => array(
      'label' => 'Test Bundle',
    ),
  );
  $bundles += array(
    $bundle => array(
      'label' => $text ? $text : $bundle,
    ),
  );
  state()
    ->set('field_test.bundles', $bundles);
  $info = entity_get_info();
  foreach ($info as $type => $type_info) {
    if ($type_info['module'] == 'field_test') {
      field_attach_create_bundle($type, $bundle);
    }
  }
}