protected function EntityReferenceFieldInheritanceFactory::computeValue in Field Inheritance 8
Same name and namespace in other branches
- 2.0.x src/EntityReferenceFieldInheritanceFactory.php \Drupal\field_inheritance\EntityReferenceFieldInheritanceFactory::computeValue()
Compute the field property from state.
Overrides ComputedItemListTrait::computeValue
File
- src/
EntityReferenceFieldInheritanceFactory.php, line 62
Class
- EntityReferenceFieldInheritanceFactory
- The EntityReferenceFieldInheritanceFactory class.
Namespace
Drupal\field_inheritanceCode
protected function computeValue() {
$entity = $this
->getEntity();
$manager = $this
->getManager();
$configuration = $this
->getSettings() + [
'entity' => $entity,
];
$plugin = $manager
->createInstance($this
->getSetting('plugin'), $configuration);
$values = $plugin
->computeValue();
if (!empty($values)) {
foreach ($values as $key => $value) {
$this->list[$key] = $this
->createItem($key, $value);
}
}
else {
$this
->applyDefaultValue();
}
}