Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ica1 on
Hi,
in my module i would like to list all config entities in my drupal 8 website,
how to do ?
Best regards
Comments
ConfigSingleExportForm.php in
ConfigSingleExportForm.php in config module is a good start :
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$this->definitions[$entity_type] = $definition;
}
}
Call from .module file :
Ask config storage
I think a better solution is to use the config.storage service:
$configNames = \Drupal::service('config.storage')->listAll('');
See CachedStorage::listAll(). If you want all node types, for example, then you can use this:
$configNames = \Drupal::service('config.storage')->listAll('node.type');