function ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalTranslation
Same name in other branches
- 9 core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php \Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalTranslation()
- 8.9.x core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php \Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalTranslation()
- 10 core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php \Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalTranslation()
Returns the original translation.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being validated.
\Drupal\Core\Entity\ContentEntityInterface $original: The original entity.
Return value
\Drupal\Core\Entity\ContentEntityInterface The original entity translation object.
1 call to ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalTranslation()
- ContentTranslationSynchronizedFieldsConstraintValidator::validate in core/
modules/ content_translation/ src/ Plugin/ Validation/ Constraint/ ContentTranslationSynchronizedFieldsConstraintValidator.php
File
-
core/
modules/ content_translation/ src/ Plugin/ Validation/ Constraint/ ContentTranslationSynchronizedFieldsConstraintValidator.php, line 194
Class
- ContentTranslationSynchronizedFieldsConstraintValidator
- Checks that synchronized fields are handled correctly in pending revisions.
Namespace
Drupal\content_translation\Plugin\Validation\ConstraintCode
protected function getOriginalTranslation(ContentEntityInterface $entity, ContentEntityInterface $original) {
// If the language of the default translation is changing, the original
// translation will be the same as the original entity, but they won't
// necessarily have the same langcode.
if ($entity->isDefaultTranslation() && $original->language()
->getId() !== $entity->language()
->getId()) {
return $original;
}
$langcode = $entity->language()
->getId();
if ($original->hasTranslation($langcode)) {
$original_langcode = $langcode;
}
else {
$metadata = $this->contentTranslationManager
->getTranslationMetadata($entity);
$original_langcode = $metadata->getSource();
}
return $original->getTranslation($original_langcode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.