protected function FieldInheritancePluginBase::getDestinationEntity in Field Inheritance 8
Same name and namespace in other branches
- 2.0.x src/Plugin/FieldInheritance/FieldInheritancePluginBase.php \Drupal\field_inheritance\Plugin\FieldInheritance\FieldInheritancePluginBase::getDestinationEntity()
Get the translated destination entity.
Return value
Drupal\Core\Entity\EntityInterface The translated destination entity.
4 calls to FieldInheritancePluginBase::getDestinationEntity()
- FieldInheritancePluginBase::appendData in src/
Plugin/ FieldInheritance/ FieldInheritancePluginBase.php - Retrieve appended data.
- FieldInheritancePluginBase::computeValue in src/
Plugin/ FieldInheritance/ FieldInheritancePluginBase.php - Compute the value of the field.
- FieldInheritancePluginBase::fallbackData in src/
Plugin/ FieldInheritance/ FieldInheritancePluginBase.php - Retrieve fallback data.
- FieldInheritancePluginBase::prependData in src/
Plugin/ FieldInheritance/ FieldInheritancePluginBase.php - Retrieve prepended data.
File
- src/
Plugin/ FieldInheritance/ FieldInheritancePluginBase.php, line 375
Class
- FieldInheritancePluginBase
- Abstract class FieldInheritancePluginBase.
Namespace
Drupal\field_inheritance\Plugin\FieldInheritanceCode
protected function getDestinationEntity() {
$context['data'] = $this->entity;
$context += [
'operation' => 'entity_view',
'langcode' => $this->langCode,
];
$candidates = $this->languageManager
->getFallbackCandidates($context);
foreach ($candidates as $candidate) {
if ($this->entity
->hasTranslation($candidate)) {
return $this->entity
->getTranslation($candidate);
}
}
return $this->entity;
}