Skip to content
Snippets Groups Projects
Commit 6ab1e697 authored by Mingsong's avatar Mingsong
Browse files

Get rid of hardcoded bundle field name to prevent potential compatible issue...

Get rid of hardcoded bundle field name to prevent potential compatible issue with entity types defined by other contributed modules
parent 0a1e1510
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,7 @@ class EntityTreeBuilder implements TreeBuilderInterface {
}
else {
$hasBundle = TRUE;
$entityStorage = \Drupal::entityTypeManager()->getStorage($entityType);
// Build the tree node for the bundle.
$tree = [
(object) [
......@@ -51,14 +52,13 @@ class EntityTreeBuilder implements TreeBuilderInterface {
'text' => $bundleID,
],
];
// The bundle field of node calls 'type'.
$bundleName = ($entityType === 'node') ? 'type' : 'bundle';
// Entity query properties.
$properties = [
$bundleName => $bundleID,
// Bundle key field.
$entityStorage->getEntityType()->getKey('bundle') => $bundleID,
];
// Load all entities matched the conditions.
$entities = \Drupal::entityTypeManager()->getStorage($entityType)->loadByProperties($properties);
$entities = $entityStorage->loadByProperties($properties);
}
// Buld the tree.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment