protected function EntityReference::prepareValue in Feeds 8.3
Prepares a single value.
Parameters
int $delta: The field delta.
array $values: The values.
Overrides FieldTargetBase::prepareValue
1 call to EntityReference::prepareValue()
- EntityReference::setTarget in src/
Feeds/ Target/ EntityReference.php - Sets the values on an object.
1 method overrides EntityReference::prepareValue()
- File::prepareValue in src/
Feeds/ Target/ File.php - Prepares a single value.
File
- src/
Feeds/ Target/ EntityReference.php, line 262
Class
- EntityReference
- Defines an entity reference mapper.
Namespace
Drupal\feeds\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
// Check if there is a value for target ID.
if (!isset($values['target_id']) || strlen(trim($values['target_id'])) === 0) {
// No value.
throw new EmptyFeedException();
}
$target_ids = $this
->findEntities($this->configuration['reference_by'], $values['target_id']);
if (empty($target_ids)) {
throw new ReferenceNotFoundException($this
->t('Referenced entity not found for field %field with value %target_id.', [
'%target_id' => $values['target_id'],
'%field' => $this->configuration['reference_by'],
]));
}
$values['target_id'] = reset($target_ids);
}