You are here

protected static function MediaTarget::callPrepareTarget in Media Feeds 8

Parameters

FieldDefinitionInterface $field:

Return value

null

1 call to MediaTarget::callPrepareTarget()
MediaTarget::prepareTarget in src/Feeds/Target/MediaTarget.php
@inheritdoc

File

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

Class

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

Namespace

Drupal\media_feeds\Feeds\Target

Code

protected static function callPrepareTarget(FieldDefinitionInterface $field) {
  $info = $field->media_feeds_info;
  $stop = null;
  $field_type = $info['type'];
  $plugin = $info['plugin'];
  if (!isset($field_type) || !isset($plugin)) {
    return null;
  }
  $class = $plugin['class'];
  if ($field instanceof FieldConfigInterface) {
    $field
      ->set('field_type', $info['type']);
  }
  $targetDef = $class::prepareTarget($field);
  $field_name = $field
    ->getName();
  $label = $field
    ->getLabel();
  $fracs = explode('(', $label);
  $old_label = $fracs[0];
  $target_bundle = $info['host']['bundle'];
  if (isset($info['host']['field'])) {
    $host_field = $info['host']['field'];
    $old_label .= ' (' . $host_field . ':' . $target_bundle . ':' . $field_name . ')';
  }
  else {
    $old_label .= ' (' . $target_bundle . ':' . $field_name . ')';
  }
  $field
    ->setLabel($old_label);
  if ($field instanceof FieldConfigInterface) {
    $field
      ->set('field_type', self::$temp_type);
  }
  return $targetDef;
}