If an entity has a bundle entity, but there are no bundle entities existing, EntityTypeBundleInfo::getAllBundleInfo() will not have a key in the return array for that entity type.
This means that for example doing this:
$entity_types = $entity_type_manager->getDefinitions();
$bundles = $entity_type_bundle_info->getAllBundleInfo();
foreach ($entity_types as $entity_type_id => $entity_type) {
foreach ($bundles[$entity_type_id] as $bundle_id => $bundle_info) {
// ...
will throw notices, and requires a guard clause to check that $bundles has the entity type present.
The documentation for getAllBundleInfo() suggests that it returns data on all entity types:
> Get the bundle info of all entity types.
So for entity types that have no bundles, there should be an empty array.
EDIT:
Steps to recreate:
1) Create module with Drupal Console: drupal gm
2) Generate a controller: drupal gcon
3) Add the following code to the controller function:
public function getHelloEntities {
$entity_types = $this->entityManager->getDefinitions();
$bundles = $this->entityManager->getAllBundleInfo();
$list = '';
foreach ($entity_types as $entity_type_id => $entity_type) {
foreach ($bundles[$entity_type_id] as $bundle_id => $bundle_info) {
$list .= $bundle_id . '::' . implode($bundle_info) . '</ br>';
}
}
return [
'#type' => 'markup',
'#markup' => $list
];
}
}
4) Go to "/admin/structure/block/block-content/types" and delete the existing bundle type entity for entity block_content.
5) Go to the controller page "/modulename/getHelloEntities
6) This will now output notices on report page of "Notice: Undefined index: block_content"