You are here

protected function EntityProcessorBase::newEntity in Feeds 8.3

1 call to EntityProcessorBase::newEntity()
EntityProcessorBase::process in src/Feeds/Processor/EntityProcessorBase.php
Processes the results from a parser.

File

src/Feeds/Processor/EntityProcessorBase.php, line 466

Class

EntityProcessorBase
Defines a base entity processor.

Namespace

Drupal\feeds\Feeds\Processor

Code

protected function newEntity(FeedInterface $feed) {
  $values = $this->configuration['values'];
  $entity = $this->storageController
    ->create($values);
  $entity
    ->enforceIsNew();
  if ($entity instanceof EntityOwnerInterface) {
    if ($this->configuration['owner_feed_author']) {
      $entity
        ->setOwnerId($feed
        ->getOwnerId());
    }
    else {
      $entity
        ->setOwnerId($this->configuration['owner_id']);
    }
  }

  // Set language if the entity type has a field for it.
  if ($this->entityType
    ->hasKey('langcode')) {
    $entity->{$this->entityType
      ->getKey('langcode')} = $this
      ->entityLanguage();
  }
  return $entity;
}