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.

6 calls to field_test_create_bundle()
BulkDeleteTest::setUp in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Set the default field storage backend for fields created during tests.
FieldAttachOtherTest::testFieldAttachPrepareViewMultiple in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
Tests the 'multiple entity' behavior of field_attach_prepare_view().
FieldAttachStorageTest::testEntityCreateRenameBundle in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test entity_bundle_create() and entity_bundle_rename().
FieldAttachStorageTest::testEntityDeleteBundle in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test entity_bundle_delete().
FieldAttachStorageTest::testFieldAttachLoadMultiple in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test the 'multiple' load feature.

... See full list

File

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

Code

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