You are here

protected function FeedsNodeProcessor::entityLoad in Feeds 8.2

Loads an existing node.

If the update existing method is not FEEDS_UPDATE_EXISTING, only the node table will be loaded, foregoing the node_load API for better performance.

@todo Reevaluate the use of node_object_prepare().

Overrides FeedsProcessor::entityLoad

File

lib/Drupal/feeds/Plugin/feeds/processor/FeedsNodeProcessor.php, line 73
Contains \Drupal\feeds\Plugin\feeds\fetcher\FeedsNodeProcessor.

Class

FeedsNodeProcessor
Defines a node processor.

Namespace

Drupal\feeds\Plugin\feeds\processor

Code

protected function entityLoad(FeedsSource $source, $nid) {
  $node = parent::entityLoad($source, $nid);
  if ($this->config['update_existing'] != FEEDS_UPDATE_EXISTING) {
    $node->uid = $this->config['author'];
  }

  // node_object_prepare($node);
  // Workaround for issue #1247506. See #1245094 for backstory.
  if (!empty($node->menu)) {

    // If the node has a menu item(with a valid mlid) it must be flagged
    // 'enabled'.
    $node->menu['enabled'] = (int) (bool) $node->menu['mlid'];
  }

  // Populate properties that are set by node_object_prepare().
  if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
    $node->log = 'Updated by FeedsNodeProcessor';
  }
  else {
    $node->log = 'Replaced by FeedsNodeProcessor';
  }
  return $node;
}