public function ContentEntityBase::hasTranslation in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::hasTranslation()
- 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::hasTranslation()
Checks there is a translation for the given language code.
Parameters
string $langcode: The language code identifying the translation.
Return value
bool TRUE if the translation exists, FALSE otherwise.
Overrides TranslatableInterface::hasTranslation
3 calls to ContentEntityBase::hasTranslation()
- ContentEntityBase::addTranslation in core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php - Adds a new translation to the translatable object.
- Media::postSave in core/
modules/ media/ src/ Entity/ Media.php - Acts on a saved entity before the insert or update hook is invoked.
- Media::prepareSave in core/
modules/ media/ src/ Entity/ Media.php - Sets the media entity's field values from the source's metadata.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php, line 934
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\EntityCode
public function hasTranslation($langcode) {
if ($langcode == $this->defaultLangcode) {
$langcode = LanguageInterface::LANGCODE_DEFAULT;
}
return !empty($this->translations[$langcode]['status']);
}