You are here

protected function FieldInheritanceFactory::computeValue in Field Inheritance 2.0.x

Same name and namespace in other branches
  1. 8 src/FieldInheritanceFactory.php \Drupal\field_inheritance\FieldInheritanceFactory::computeValue()

Compute the field property from state.

Overrides ComputedItemListTrait::computeValue

File

src/FieldInheritanceFactory.php, line 58

Class

FieldInheritanceFactory
The FieldInheritanceFactory class.

Namespace

Drupal\field_inheritance

Code

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();
  }
}