protected function LingotekSourceStatusFormatter::viewValue in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 4.0.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.0.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.1.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.2.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.3.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.4.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.5.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.6.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
- 3.7.x src/Plugin/Field/FieldFormatter/LingotekSourceStatusFormatter.php \Drupal\lingotek\Plugin\Field\FieldFormatter\LingotekSourceStatusFormatter::viewValue()
Generate the output appropriate for one field item.
Parameters
\Drupal\Core\Field\FieldItemInterface $item: One field item.
Return value
array The textual output generated as a render array.
Overrides LanguageFormatter::viewValue
File
- src/
Plugin/ Field/ FieldFormatter/ LingotekSourceStatusFormatter.php, line 51
Class
- LingotekSourceStatusFormatter
- Plugin implementation of the 'lingotek_translation_status' formatter.
Namespace
Drupal\lingotek\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
$entity = $item
->getEntity();
$source_status = Lingotek::STATUS_UNTRACKED;
if ($entity instanceof LingotekContentMetadata) {
// $entity is the metadata of another entity. Let's get the source.
// ToDo: Use injected service. See https://www.drupal.org/project/drupal/issues/2981025#comment-12707077.
$entity = \Drupal::entityTypeManager()
->getStorage($entity
->getContentEntityTypeId())
->load($entity
->getContentEntityId());
$source_status = \Drupal::service('lingotek.content_translation')
->getSourceStatus($entity);
}
$data = [
'data' => [
'#type' => 'lingotek_source_status',
'#entity' => $entity,
'#language' => $item->language,
'#status' => $source_status,
],
'#attached' => [
'library' => [
'lingotek/lingotek',
],
],
'#cache' => [
'max-age' => 0,
],
];
if ($source_status == Lingotek::STATUS_EDITED && !\Drupal::service('lingotek.content_translation')
->getDocumentId($entity)) {
$data['data']['#context']['status'] = strtolower(Lingotek::STATUS_REQUEST);
}
return $data;
}