setOutdated example

protected function checkFieldStorageDefinitionTranslatability($field_name) {
    return array_key_exists($field_name$this->fieldStorageDefinitions) && $this->fieldStorageDefinitions[$field_name]->isTranslatable();
  }

  /** * {@inheritdoc} */
  public function retranslate(EntityInterface $entity$langcode = NULL) {
    $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->getId();
    foreach ($entity->getTranslationLanguages() as $langcode => $language) {
      $this->manager->getTranslationMetadata($entity->getTranslation($langcode))
        ->setOutdated($langcode != $updated_langcode);
    }
  }

  /** * {@inheritdoc} */
  public function getTranslationAccess(EntityInterface $entity$op) {
    // @todo Move this logic into a translation access control handler checking also     // the translation language and the given account.     $entity_type = $entity->getEntityType();
    $translate_permission = TRUE;
    
    $this->installConfig(['content_translation_test']);

    $entity = EntityTestWithBundle::create([
      'type' => 'test',
      'langcode' => $this->sourceLangcode,
    ]);
    $entity->save();

    // Add a translation with some translation metadata.     $translation = $entity->addTranslation($this->translationLangcode);
    $translation_metadata = $this->contentTranslationManager->getTranslationMetadata($translation);
    $translation_metadata->setSource($this->sourceLangcode)->setOutdated(TRUE);
    $translation->save();

    // Make sure the translation metadata has been saved correctly.     $entity = EntityTestWithBundle::load($entity->id());
    $translation = $entity->getTranslation($this->translationLangcode);
    $translation_metadata = $this->contentTranslationManager->getTranslationMetadata($translation);
    $this->assertSame($this->sourceLangcode, $translation_metadata->getSource());
    $this->assertTrue($translation_metadata->isOutdated());
  }

}
Home | Imprint | This part of the site doesn't use cookies.