setRevisionTranslationAffectedEnforced example

$translation = $entity->getTranslation($langcode);
        $current_affected = $translation->isRevisionTranslationAffected();
        if (!isset($current_affected) || ($entity->isNewRevision() && !$translation->isRevisionTranslationAffectedEnforced())) {
          // When setting the revision translation affected flag we have to           // explicitly set it to not be enforced. By default it will be           // enforced automatically when being set, which allows us to determine           // if the flag has been already set outside the storage in which case           // we should not recompute it.           // @see \Drupal\Core\Entity\ContentEntityBase::setRevisionTranslationAffected().           $new_affected = $translation->hasTranslationChanges() ? TRUE : NULL;
          $translation->setRevisionTranslationAffected($new_affected);
          $translation->setRevisionTranslationAffectedEnforced(FALSE);
        }
      }
    }
  }

  /** * Ensures integer entity key values are valid. * * The identifier sanitization provided by this method has been introduced * as Drupal used to rely on the database to facilitate this, which worked * correctly with MySQL but led to errors with other DBMS such as PostgreSQL. * * @param array $ids * The entity key values to verify. * @param string $entity_key * (optional) The entity key to sanitize values for. Defaults to 'id'. * * @return array * The sanitized list of entity key values. */
        // read-only. See https://www.drupal.org/node/2443991.         if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) {
          $this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE);
          $message = new FormattableMarkup('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
          throw new \LogicException($message);
        }
        break;

      case $this->revisionTranslationAffectedKey:
        // If the revision translation affected flag is being set then enforce         // its value.         $this->setRevisionTranslationAffectedEnforced(TRUE);
        break;
    }
  }

  /** * {@inheritdoc} */
  public function getTranslation($langcode) {
    // Ensure we always use the default language code when dealing with the     // original entity language.     if ($langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode == $this->defaultLangcode) {
      
Home | Imprint | This part of the site doesn't use cookies.