You are here

protected function LingotekTranslationSourceField::computeValue in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  2. 4.0.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  3. 3.0.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  4. 3.1.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  5. 3.3.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  6. 3.4.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  7. 3.5.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  8. 3.6.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  9. 3.7.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()
  10. 3.8.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php \Drupal\lingotek\Plugin\Field\FieldType\LingotekTranslationSourceField::computeValue()

Compute the values.

Overrides ComputedItemListTrait::computeValue

File

src/Plugin/Field/FieldType/LingotekTranslationSourceField.php, line 16

Class

LingotekTranslationSourceField

Namespace

Drupal\lingotek\Plugin\Field\FieldType

Code

protected function computeValue() {
  $metadata = $this
    ->getEntity();
  $entity_type_id = $metadata
    ->getContentEntityTypeId();
  $entity_id = $metadata
    ->getContentEntityId();
  if ($entity_type_id && $entity_id) {
    $target_entity = \Drupal::entityTypeManager()
      ->getStorage($entity_type_id)
      ->load($entity_id);
    if ($target_entity) {
      $this->list[0] = $this
        ->createItem(0, $target_entity
        ->language()
        ->getId());
    }
  }
}