You are here

public function FieldTargetBase::getEntityTarget in Feeds 8.3

Get entity, or entity translation to set the map.

Parameters

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

\Drupal\Core\Entity\EntityInterface $entity: The entity to import.

Return value

\Drupal\Core\Entity\EntityInterface|null Self entity or entity translation.

See also

\Drupal\feeds\Plugin\Type\Target\FieldTargetBase::isTargetTranslatable()

5 calls to FieldTargetBase::getEntityTarget()
ConfigEntityReference::setTarget in src/Feeds/Target/ConfigEntityReference.php
Sets the values on an object.
EntityReference::setTarget in src/Feeds/Target/EntityReference.php
Sets the values on an object.
FeedsItem::setTarget in src/Feeds/Target/FeedsItem.php
Sets the values on an object.
FieldTargetBase::setTarget in src/Plugin/Type/Target/FieldTargetBase.php
Sets the values on an object.
UserRole::setTarget in src/Feeds/Target/UserRole.php
Sets the values on an object.

File

src/Plugin/Type/Target/FieldTargetBase.php, line 132

Class

FieldTargetBase
Helper class for field mappers.

Namespace

Drupal\feeds\Plugin\Type\Target

Code

public function getEntityTarget(FeedInterface $feed, EntityInterface $entity) {
  if ($entity instanceof TranslatableInterface && $this
    ->isTargetTranslatable()) {
    if ($this
      ->languageExists()) {
      $processor = $feed
        ->getType()
        ->getProcessor();
      if ($processor instanceof EntityProcessorInterface) {
        return $processor
          ->getEntityTranslation($feed, $entity, $this
          ->getLangcode());
      }
    }
    return;
  }
  return $entity;
}