You are here

protected static function MediaTarget::getPlugin in Media Feeds 8

Parameters

FieldDefinitionInterface $field:

ProcessorInterface|null $processor:

Return value

null

1 call to MediaTarget::getPlugin()
MediaTarget::getSubFields in src/Feeds/Target/MediaTarget.php

File

src/Feeds/Target/MediaTarget.php, line 239

Class

MediaTarget
Defines a wrapper target around a paragraph bundle's target field.

Namespace

Drupal\media_feeds\Feeds\Target

Code

protected static function getPlugin(FieldDefinitionInterface $field, ProcessorInterface $processor = null) {
  $targetsManager = \Drupal::service('plugin.manager.feeds.target');
  $plugins = $targetsManager
    ->getDefinitions();
  $id = null;
  if ($field instanceof FieldConfigInterface) {
    $id = $field
      ->id();
  }
  else {
    if ($field instanceof BaseFieldDefinition) {
      $id = $field
        ->getUniqueIdentifier();
    }
  }
  if ($field
    ->isReadOnly() || isset($processor) && $id === $processor
    ->bundleKey()) {
    return null;
  }
  foreach ($plugins as $plugin) {
    if (in_array($field
      ->getType(), $plugin['field_types'])) {
      return $plugin;
    }
  }
  return null;
}