You are here

public function ConfigManager::findVariantMappings in UI Patterns Settings 8.2

Find all variant mappings.

Return value

string[] List of all variant mappings.

File

src/ConfigManager.php, line 68

Class

ConfigManager
UI Patterns setting factory class.

Namespace

Drupal\ui_patterns_settings

Code

public function findVariantMappings($type) {
  if (isset($this->variantMap[$type])) {
    return $this->variantMap[$type];
  }
  $map = is_array($this->config
    ->get('mapping')) ? $this->config
    ->get('mapping') : [];
  foreach ($map as $field_id => $pattern_string) {
    [
      $pattern_id,
      $setting_id,
    ] = explode('::', $pattern_string);
    [
      $entity_type_id,
      $field_name,
    ] = explode('--', $field_id);
    if ($setting_id === 'variant') {
      $this->variantMap[$type][] = $field_name;
    }
  }
  if (!isset($this->variantMap[$type])) {
    $this->variantMap[$type] = [];
  }
  return $this->variantMap[$type];
}