You are here

protected function FieldInheritancePluginBase::prependData in Field Inheritance 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/FieldInheritance/FieldInheritancePluginBase.php \Drupal\field_inheritance\Plugin\FieldInheritance\FieldInheritancePluginBase::prependData()

Retrieve prepended data.

Return value

string The prepended data.

1 call to FieldInheritancePluginBase::prependData()
FieldInheritancePluginBase::computeValue in src/Plugin/FieldInheritance/FieldInheritancePluginBase.php
Compute the value of the field.

File

src/Plugin/FieldInheritance/FieldInheritancePluginBase.php, line 241

Class

FieldInheritancePluginBase
Abstract class FieldInheritancePluginBase.

Namespace

Drupal\field_inheritance\Plugin\FieldInheritance

Code

protected function prependData() {
  $source_entity = $this
    ->getSourceEntity();
  $destination_entity = $this
    ->getDestinationEntity();
  $values = [];
  if ($source_entity === FALSE) {
    return $values;
  }
  if (!empty($destination_entity->{$this
    ->getDestinationField()}
    ->getValue())) {
    $values = array_merge($values, $destination_entity->{$this
      ->getDestinationField()}
      ->getValue());
  }
  if (!empty($source_entity->{$this
    ->getSourceField()}
    ->getValue())) {
    $values = array_merge($values, $source_entity->{$this
      ->getSourceField()}
      ->getValue());
  }
  return $values;
}