Hi,

in my module i would like to list all config entities in my drupal 8 website,

how to do ?

Best regards

Comments

ica1’s picture

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 :

\Drupal::EntityTypeManager()->entityManager->getDefinitions()
benjifisher’s picture

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');