Implements hook_entity_bundle_info_alter().
function field_test_entity_bundle_info_alter(&$bundles) {
$entity_info = entity_get_info();
foreach ($bundles as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'field_test') {
$bundles[$entity_type] = Drupal::state()
->get('field_test_bundles') ?: array(
'test_bundle' => array(
'label' => 'Test Bundle',
),
);
if ($entity_type == 'test_entity_bundle') {
$bundles[$entity_type] += array(
'test_entity_2' => array(
'label' => 'Test entity 2',
),
);
}
if ($entity_type == 'test_entity_bundle_key') {
$bundles[$entity_type] += array(
'bundle1' => array(
'label' => 'Bundle1',
),
'bundle2' => array(
'label' => 'Bundle2',
),
);
}
}
}
}