You are here

public function Language::setTarget in Feeds 8.3

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/Language.php, line 24

Class

Language
Defines a language field mapper.

Namespace

Drupal\feeds\Feeds\Target

Code

public function setTarget(FeedInterface $feed, EntityInterface $entity, $field_name, array $values) {
  if ($values = $this
    ->prepareValues($values)) {
    $langcode = isset($values[0]['value']) ? $values[0]['value'] : NULL;
    if (!empty($langcode)) {
      $entity
        ->set($field_name, $langcode);
    }
  }
}