public function EntityHelper::getEntityInstanceIds in Simple XML sitemap 8.3
Gets the entity IDs by entity type and bundle.
Parameters
string $entity_type_id: The entity type ID.
string|null $bundle_name: The bundle name.
Return value
array An array of entity IDs
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
EntityHelper.php, line 197
Class
- EntityHelper
- Helper class for working with entities.
Namespace
Drupal\simple_sitemapCode
public function getEntityInstanceIds($entity_type_id, $bundle_name = NULL) {
$sitemap_entity_types = $this
->getSupportedEntityTypes();
if (!isset($sitemap_entity_types[$entity_type_id])) {
return [];
}
$entity_query = $this->entityTypeManager
->getStorage($entity_type_id)
->getQuery();
if (!$this
->entityTypeIsAtomic($entity_type_id) && NULL !== $bundle_name) {
$keys = $sitemap_entity_types[$entity_type_id]
->getKeys();
// Menu fix.
$keys['bundle'] = $entity_type_id === 'menu_link_content' ? 'menu_name' : $keys['bundle'];
$entity_query
->condition($keys['bundle'], $bundle_name);
}
return $entity_query
->execute();
}