public function EntityProcessorBase::getEntityTranslation in Feeds 8.3
Returns a translation of the given entity.
If a translation of the requested language does not exist yet on the entity, one is created.
Parameters
\Drupal\feeds\FeedInterface $feed: The feed that controls the import.
\Drupal\Core\Entity\TranslatableInterface $entity: A translatable entity.
string $langcode: The language in which to get the translation.
Return value
\Drupal\Core\Entity\EntityInterface The translated entity.
Overrides EntityProcessorInterface::getEntityTranslation
File
- src/
Feeds/ Processor/ EntityProcessorBase.php, line 491
Class
- EntityProcessorBase
- Defines a base entity processor.
Namespace
Drupal\feeds\Feeds\ProcessorCode
public function getEntityTranslation(FeedInterface $feed, TranslatableInterface $entity, $langcode) {
if (!$entity
->hasTranslation($langcode)) {
$translation = $entity
->addTranslation($langcode);
if ($translation instanceof EntityOwnerInterface) {
if ($this->configuration['owner_feed_author']) {
$translation
->setOwnerId($feed
->getOwnerId());
}
else {
$translation
->setOwnerId($this->configuration['owner_id']);
}
}
return $translation;
}
return $entity
->getTranslation($langcode);
}