hasDestinationProperty example

$this->assertSame($this->testValues['nid']$row->getSourceProperty('nid'));
    $this->assertSame($this->testValues['title']$row->getSourceProperty('title'));
    $this->assertNull($row->getSourceProperty('non_existing'));
  }

  /** * Tests setting and getting the destination. */
  public function testDestination() {
    $row = new Row($this->testValues, $this->testSourceIds);
    $this->assertEmpty($row->getDestination());
    $this->assertFalse($row->hasDestinationProperty('nid'));

    // Set a destination.     $row->setDestinationProperty('nid', 2);
    $this->assertTrue($row->hasDestinationProperty('nid'));
    $this->assertEquals(['nid' => 2]$row->getDestination());
  }

  /** * Tests setting/getting multiple destination IDs. */
  public function testMultipleDestination() {
    

  protected function updateEntity(EntityInterface $entity, Row $row) {
    // This is a translation if the language in the active config does not     // match the language of this row.     $translation = FALSE;
    if ($this->isTranslationDestination() && $row->hasDestinationProperty('langcode') && $this->languageManager instanceof ConfigurableLanguageManager) {
      $config = $entity->getConfigDependencyName();
      $langcode = $this->configFactory->get('langcode');
      if ($langcode != $row->getDestinationProperty('langcode')) {
        $translation = TRUE;
      }
    }

    if ($translation) {
      if (!$row->hasDestinationProperty('property')) {
        throw new \LogicException('The "property" property is required');
      }
      

  protected function updateEntity(EntityInterface $entity, Row $row) {
    $empty_destinations = $row->getEmptyDestinationProperties();
    // By default, an update will be preserved.     $rollback_action = MigrateIdMapInterface::ROLLBACK_PRESERVE;

    // Make sure we have the right translation.     if ($this->isTranslationDestination()) {
      $property = $this->storage->getEntityType()->getKey('langcode');
      if ($row->hasDestinationProperty($property)) {
        $language = $row->getDestinationProperty($property);
        if (!$entity->hasTranslation($language)) {
          $entity->addTranslation($language);

          // We're adding a translation, so delete it on rollback.           $rollback_action = MigrateIdMapInterface::ROLLBACK_DELETE;
        }
        $entity = $entity->getTranslation($language);
      }
    }

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