You are here

protected function ConfigName::parseFullName in Update helper 2.x

Same name and namespace in other branches
  1. 8 src/ConfigName.php \Drupal\update_helper\ConfigName::parseFullName()

Parse full config name and create array with config type and name.

Parameters

string $full_config_name: Full config name.

Return value

array Returns array with config type and name.

File

src/ConfigName.php, line 84

Class

ConfigName
Configuration name class for easier handling of configuration references.

Namespace

Drupal\update_helper

Code

protected function parseFullName($full_config_name) {
  $result = [
    'type' => static::SYSTEM_SIMPLE_CONFIG,
    'name' => $full_config_name,
  ];
  $prefix = static::SYSTEM_SIMPLE_CONFIG . '.';
  if (strpos($full_config_name, $prefix)) {
    $result['name'] = substr($full_config_name, strlen($prefix));
  }
  else {
    foreach ($this
      ->entityTypeManager()
      ->getDefinitions() as $entityType => $definition) {
      if ($definition
        ->entityClassImplements('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
        $prefix = $definition
          ->getConfigPrefix() . '.';
        if (strpos($full_config_name, $prefix) === 0) {
          $result['type'] = $entityType;
          $result['name'] = substr($full_config_name, strlen($prefix));
        }
      }
    }
  }
  return $result;
}