Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentTranslationSynchronizedFieldsConstraintValidator.php

function ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalEntity

Returns the original unchanged entity to be used to detect changes.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being changed.

Return value

\Drupal\Core\Entity\ContentEntityInterface The unchanged entity.

1 call to ContentTranslationSynchronizedFieldsConstraintValidator::getOriginalEntity()
ContentTranslationSynchronizedFieldsConstraintValidator::validate in core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php
Checks if the passed value is valid.

File

core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php, line 171

Class

ContentTranslationSynchronizedFieldsConstraintValidator
Checks that synchronized fields are handled correctly in pending revisions.

Namespace

Drupal\content_translation\Plugin\Validation\Constraint

Code

protected function getOriginalEntity(ContentEntityInterface $entity) {
    if (!isset($entity->original)) {
        
        /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
        $storage = $this->entityTypeManager
            ->getStorage($entity->getEntityTypeId());
        $original = $entity->isDefaultRevision() ? $storage->loadUnchanged($entity->id()) : $storage->loadRevision($entity->getLoadedRevisionId());
    }
    else {
        $original = $entity->original;
    }
    return $original;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal