function ConfigManager::getEntityTypeIdByName

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::getEntityTypeIdByName()
  2. 8.9.x core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::getEntityTypeIdByName()
  3. 11.x core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::getEntityTypeIdByName()

Returns the entity type of a configuration object.

Parameters

string $name: The configuration object name.

Return value

string|null Either the entity type name, or NULL if none match.

Overrides ConfigManagerInterface::getEntityTypeIdByName

2 calls to ConfigManager::getEntityTypeIdByName()
ConfigManager::findConfigEntityDependenciesAsEntities in core/lib/Drupal/Core/Config/ConfigManager.php
Finds config entities that are dependent on extensions or entities.
ConfigManager::loadConfigEntityByName in core/lib/Drupal/Core/Config/ConfigManager.php
Loads a configuration entity using the configuration name.

File

core/lib/Drupal/Core/Config/ConfigManager.php, line 121

Class

ConfigManager
The ConfigManager provides helper functions for the configuration system.

Namespace

Drupal\Core\Config

Code

public function getEntityTypeIdByName($name) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if ($entity_type instanceof ConfigEntityTypeInterface && ($config_prefix = $entity_type->getConfigPrefix()) && str_starts_with($name, $config_prefix . '.')) {
      return $entity_type_id;
    }
  }
  return NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.