function entity_test_entity_bundle_info

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

Implements hook_entity_bundle_info().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 228

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' && !in_array($entity_type_id, [
            'entity_test_with_bundle',
            'entity_test_mul_with_bundle',
        ], TRUE)) {
            $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles', [
                $entity_type_id => [
                    'label' => 'Entity Test Bundle',
                ],
            ]);
        }
    }
    return $bundles;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.