protected function ConfigEntityReference::prepareValue in Feeds 8.3
Prepares a single value.
Parameters
int $delta: The field delta.
array $values: The values.
Overrides FieldTargetBase::prepareValue
2 calls to ConfigEntityReference::prepareValue()
- ConfigEntityReference::setTarget in src/
Feeds/ Target/ ConfigEntityReference.php - Sets the values on an object.
- UserRole::prepareValue in src/
Feeds/ Target/ UserRole.php - Prepares a single value.
1 method overrides ConfigEntityReference::prepareValue()
- UserRole::prepareValue in src/
Feeds/ Target/ UserRole.php - Prepares a single value.
File
- src/
Feeds/ Target/ ConfigEntityReference.php, line 206
Class
- ConfigEntityReference
- Defines a config 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();
}
if ($target_id = $this
->findEntity($this->configuration['reference_by'], $values['target_id'])) {
$values['target_id'] = $target_id;
return;
}
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'],
]));
}