protected function FeedsEntityProcessor::newEntity in Feeds entity processor 7
Implements FeedsProcessor::newEntity().
File
- src/
FeedsEntityProcessor.inc, line 111 - Contains FeedsEntityProcessor.
Class
- FeedsEntityProcessor
- Creates entities from feed items.
Code
protected function newEntity(FeedsSource $source) {
if ($bundle_key = $this
->bundleKey()) {
$entity = entity_create($this
->entityType(), array(
$bundle_key => $this
->bundle(),
) + $this->config['values']);
}
else {
$entity = entity_create($this
->entityType(), $this->config['values']);
}
// Set created/changed date. The entity type may support these values.
$entity->created = REQUEST_TIME;
$entity->changed = REQUEST_TIME;
// Set properties on the entity.
foreach ($this
->entityProperties() as $name => $property) {
if (isset($this->config['values'][$name]) && $this->config['values'][$name] !== '') {
$plugin = feeds_entity_processor_plugin($name, $property, $this
->entityWrapper($entity), $this);
$plugin
->setValue($this->config['values'][$name], array());
}
}
return $entity;
}