getTranslatableFields example

'sourceid1' => 2,
      'destid1' => NULL,
      'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
    ]);
    $node = Node::load(2);
    $this->assertSame($title$node->getTitle());

    // Test synchronized field.     $value = 'jsmith@example.com';
    $node = Node::load(21);
    $this->assertSame($value$node->field_sync->value);
    $this->assertArrayNotHasKey('field_sync', $node->getTranslatableFields());

    $node = $node->getTranslation('fr');
    $this->assertSame($value$node->field_sync->value);
  }

  /** * Execute the migration a second time. * * @param array $new_row * An optional row to be inserted into the id map. * * @return string * The new title in the source for vid 3. */
foreach ($translation_languages as $langcode => $language) {
        if ($langcode == $active_langcode) {
          continue;
        }

        $default_revision_translation = $default_revision->getTranslation($langcode);
        $new_revision_translation = $new_revision->hasTranslation($langcode) ?
          $new_revision->getTranslation($langcode) : $new_revision->addTranslation($langcode);

        /** @var \Drupal\Core\Field\FieldItemListInterface[] $sync_items */
        $sync_items = array_diff_key(
          $keep_untranslatable_fields ? $default_revision_translation->getTranslatableFields() : $default_revision_translation->getFields(),
          $skipped_field_names
        );
        foreach ($sync_items as $field_name => $items) {
          $new_revision_translation->set($field_name$items->getValue());
        }

        // Make sure the "revision_translation_affected" flag is recalculated.         $new_revision_translation->setRevisionTranslationAffected(NULL);

        // No need to copy untranslatable field values more than once.         $keep_untranslatable_fields = TRUE;
      }
$node = Node::load(6);
    $this->assertEquals(CommentItemInterface::CLOSED, $node->comment_forum->status);

    $node = Node::load(7);
    $this->assertEquals(CommentItemInterface::OPEN, $node->comment_forum->status);

    // Test synchronized field.     $value = 'Kai Opaka';
    $node = Node::load(2);
    $this->assertSame($value$node->field_text_plain->value);
    $this->assertArrayNotHasKey('field_text_plain', $node->getTranslatableFields());

    $node = $node->getTranslation('is');
    $this->assertSame($value$node->field_text_plain->value);

    // Tests node entity translations migration from Drupal 7 to 8.     $manager = $this->container->get('content_translation.manager');

    // Get the node and its translations.     $node = Node::load(1);
    $node_fr = $node->getTranslation('fr');
    $node_is = $node->getTranslation('is');

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