function EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges()
- 8.9.x core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityUntranslatableFieldsConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityUntranslatableFieldsConstraintValidator::hasUntranslatableFieldsChanges()
- 10 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 {
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage($entity->getEntityTypeId());
$original = $storage->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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.