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);
}
doc_Drupal
2016-10-29 08:54:00
Comments
Leave a Comment

Please login to continue.