You are here

function certificate_get_certificate_mappers in Certificate 4.x

Get mapper options

File

./certificate.module, line 151

Code

function certificate_get_certificate_mappers(BaseFieldDefinition $definition = NULL, ContentEntityInterface $entity = NULL) {
  $options = [];
  $certificate_mappers = Drupal::service('plugin.manager.certificate_mapper');
  $mapper_definitions = $certificate_mappers
    ->getDefinitions();
  foreach ($mapper_definitions as $map_type => $map) {
    $plugin = $certificate_mappers
      ->createInstance($map_type, [
      'of' => 'configuration values',
    ]);

    // Skip plugins that are missing dependent modules
    if (!$plugin
      ->hasDependencies()) {
      continue;
    }
    $options[$map_type] = $map['label'];
  }
  return $options;
}