You are here

function entity_test_entity_bundle_info in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_bundle_info()

Implements hook_entity_bundle_info().

1 string reference to 'entity_test_entity_bundle_info'
KernelTestBaseTest::testSetUp in core/modules/simpletest/src/Tests/KernelTestBaseTest.php
Tests expected behavior of setUp().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 224
Test module for the entity API providing several entity types for testing.

Code

function entity_test_entity_bundle_info() {
  $bundles = [];
  $entity_types = \Drupal::entityTypeManager()
    ->getDefinitions();
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type
      ->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') {
      $bundles[$entity_type_id] = \Drupal::state()
        ->get($entity_type_id . '.bundles') ?: [
        $entity_type_id => [
          'label' => 'Entity Test Bundle',
        ],
      ];
    }
  }
  return $bundles;
}