You are here

public function WebformContentCreatorFieldMappingManager::getFieldMappings in Webform Content Creator 3.x

File

src/Plugin/WebformContentCreatorFieldMappingManager.php, line 40

Class

WebformContentCreatorFieldMappingManager
Plugin manager for finding and using field mapping types.

Namespace

Drupal\webform_content_creator\Plugin

Code

public function getFieldMappings(string $field_type) {
  $instances = $configuration = [];
  $plugin_definitions = $this
    ->getDefinitions();
  usort($plugin_definitions, function ($definition1, $definition2) {
    return $definition1['weight'] <=> $definition1['weight'];
  });
  foreach ($this
    ->getDefinitions() as $field_mapping) {
    if (in_array($field_type, $field_mapping['field_types']) || empty($field_mapping['field_types'])) {
      $instances[] = $this
        ->createInstance($field_mapping['id'], $configuration)
        ->getPlugin();
    }
  }
  return $instances;
}