public function FeedsEntityProcessorPropertyEntity::setValue in Feeds entity processor 7
Implements FeedsEntityProcessorPropertyInterface::setValue().
Overrides FeedsEntityProcessorPropertyDefault::setValue
File
- src/
Property/ FeedsEntityProcessorPropertyEntity.php, line 157 - Contains FeedsEntityProcessorPropertyEntity.
Class
- FeedsEntityProcessorPropertyEntity
- Handler for entity property.
Code
public function setValue($value, array $mapping) {
$wrapper = NULL;
if (is_scalar($value)) {
$entity_type = $this
->getMappingEntityType($mapping);
if (!$entity_type) {
throw new FeedsValidationException(t('Mapping option %name not set for target %target.', array(
'%name' => t('Entity type'),
'%target' => !empty($mapping['target']) ? $mapping['target'] : $this
->getName(),
)));
}
$wrapper = entity_metadata_wrapper($entity_type, $value);
}
if (is_array($value) && !empty($value['entity_type']) && !empty($value['entity_id'])) {
$wrapper = entity_metadata_wrapper($value['entity_type'], $value['entity_id']);
}
if ($wrapper) {
parent::setValue($wrapper, $mapping);
}
}