protected function EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges()
- 9 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges()
Checks whether an entity has untranslatable field changes.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: A content entity object.
Return value
bool TRUE if untranslatable fields have changes, FALSE otherwise.
1 call to EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges()
- EntityUntranslatableFieldsConstraintValidator::validate in core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ EntityUntranslatableFieldsConstraintValidator.php
File
- core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ EntityUntranslatableFieldsConstraintValidator.php, line 96
Class
- EntityUntranslatableFieldsConstraintValidator
- Validates the EntityChanged constraint.
Namespace
Drupal\Core\Entity\Plugin\Validation\ConstraintCode
protected function hasUntranslatableFieldsChanges(ContentEntityInterface $entity) {
$skip_fields = $this
->getFieldsToSkipFromTranslationChangesCheck($entity);
/** @var \Drupal\Core\Entity\ContentEntityInterface $original */
if (isset($entity->original)) {
$original = $entity->original;
}
else {
$original = $this->entityTypeManager
->getStorage($entity
->getEntityTypeId())
->loadRevision($entity
->getLoadedRevisionId());
}
foreach ($entity
->getFieldDefinitions() as $field_name => $definition) {
if (in_array($field_name, $skip_fields, TRUE) || $definition
->isTranslatable() || $definition
->isComputed()) {
continue;
}
$items = $entity
->get($field_name)
->filterEmptyItems();
$original_items = $original
->get($field_name)
->filterEmptyItems();
if ($items
->hasAffectingChanges($original_items, $entity
->getUntranslated()
->language()
->getId())) {
return TRUE;
}
}
return FALSE;
}