LingotekTranslationSourceField.php in Lingotek Translation 3.4.x
Same filename and directory in other branches
- 8.2 src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 4.0.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.0.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.1.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.2.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.3.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.5.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.6.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.7.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
- 3.8.x src/Plugin/Field/FieldType/LingotekTranslationSourceField.php
Namespace
Drupal\lingotek\Plugin\Field\FieldTypeFile
src/Plugin/Field/FieldType/LingotekTranslationSourceField.phpView source
<?php
namespace Drupal\lingotek\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\TypedData\ComputedItemListTrait;
class LingotekTranslationSourceField extends FieldItemList implements FieldItemListInterface {
use ComputedItemListTrait;
/**
* Compute the values.
*/
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());
}
}
}
}
Classes
Name | Description |
---|---|
LingotekTranslationSourceField |