public function ConfigManager::getEntityTypeIdByName

public ConfigManager::getEntityTypeIdByName($name)

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

File

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

Class

ConfigManager
The ConfigManager provides helper functions for the configuration system.

Namespace

Drupal\Core\Config

Code

public function getEntityTypeIdByName($name) {
  $entities = array_filter($this->entityManager->getDefinitions(), function(EntityTypeInterface $entity_type) use ($name) {
    return ($entity_type instanceof ConfigEntityTypeInterface && $config_prefix = $entity_type->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0;
  });
  return key($entities);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigManager.php/function/ConfigManager::getEntityTypeIdByName/8.1.x