You are here

public function WrapperTarget::setTarget in Feeds Paragraphs 8

Sets the values on an object.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed object.

\Drupal\Core\Entity\EntityInterface $entity: The target object.

string $target: The name of the target to set.

array $values: A list of values to set on the target.

Overrides FieldTargetBase::setTarget

File

src/Feeds/Target/WrapperTarget.php, line 136

Class

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

Namespace

Drupal\feeds_para_mapper\Feeds\Target

Code

public function setTarget(FeedInterface $feed, EntityInterface $entity, $field_name, array $values) {
  $empty = $this
    ->valuesAreEmpty($values);
  if ($empty) {
    return;
  }
  $target = $this->targetDefinition;
  $target = $target
    ->getFieldDefinition();
  $type = $this->mapper
    ->getInfo($target, 'type');
  $target
    ->set('field_type', $type);
  try {
    $importer = \Drupal::service('feeds_para_mapper.importer');
    $importer
      ->import($this->feedType, $feed, $entity, $target, $this->configuration, $values, $this->targetInstance);
  } catch (\Exception $exception) {
    $this->messenger
      ->addError($exception);
  }
}