You are here

protected function FeedsProcessor::entityLoad in Feeds 7.2

Loads an existing entity.

@todo We should be able to batch load these, if we found all of the existing ids first.

Parameters

FeedsSource $source: The feeds source that spawns this entity.

mixed $entity_id: The id of the entity to load.

Return value

object A new entity object.

4 calls to FeedsProcessor::entityLoad()
FeedsNodeProcessor::entityLoad in plugins/FeedsNodeProcessor.inc
Loads an existing node.
FeedsProcessor::process in plugins/FeedsProcessor.inc
Process the result of the parsing stage.
FeedsTermProcessor::entityLoad in plugins/FeedsTermProcessor.inc
Load an existing entity.
FeedsUserProcessor::entityLoad in plugins/FeedsUserProcessor.inc
Loads an existing user.
3 methods override FeedsProcessor::entityLoad()
FeedsNodeProcessor::entityLoad in plugins/FeedsNodeProcessor.inc
Loads an existing node.
FeedsTermProcessor::entityLoad in plugins/FeedsTermProcessor.inc
Load an existing entity.
FeedsUserProcessor::entityLoad in plugins/FeedsUserProcessor.inc
Loads an existing user.

File

plugins/FeedsProcessor.inc, line 140
Contains FeedsProcessor and related classes.

Class

FeedsProcessor
Abstract class, defines interface for processors.

Code

protected function entityLoad(FeedsSource $source, $entity_id) {
  $info = $this
    ->entityInfo();
  if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
    $entities = entity_load($this
      ->entityType(), array(
      $entity_id,
    ));
    $entity = reset($entities);
  }
  else {
    $args = array(
      ':entity_id' => $entity_id,
    );
    $table = db_escape_table($info['base table']);
    $key = db_escape_field($info['entity keys']['id']);
    $entity = db_query("SELECT * FROM {" . $table . "} WHERE {$key} = :entity_id", $args)
      ->fetchObject();
  }
  if ($entity && !empty($info['entity keys']['language'])) {
    $entity->{$info['entity keys']['language']} = $this
      ->entityLanguage();
  }
  return $entity;
}