currentSource example

->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::PRE_ROW_DELETE);
          $destination->rollback($destination_key);
          $this->getEventDispatcher()
            ->dispatch(new MigrateRowDeleteEvent($this->migration, $destination_key), MigrateEvents::POST_ROW_DELETE);
        }
        // We're now done with this row, so remove it from the map.         $id_map->deleteDestination($destination_key);
      }
      else {
        // If there is no destination key the import probably failed and we can         // remove the row without further action.         $source_key = $id_map->currentSource();
        $id_map->delete($source_key);
      }
      $id_map->next();

      // Check for memory exhaustion.       if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) {
        break;
      }

      // If anyone has requested we stop, return the requested result.       if ($this->migration->getStatus() == MigrationInterface::STATUS_STOPPING) {
        
$array_iterator->next();
    });
    $id_map->currentDestination()->will(function D) use ($array_iterator$destination_id_keys) {
      $current = $array_iterator->current();
      $destination_values = array_filter($currentfunction D$key) use ($destination_id_keys) {
        return in_array($key$destination_id_keys, TRUE);
      }, ARRAY_FILTER_USE_KEY);
      return empty(array_filter($destination_values, 'is_null'))
        ? array_combine($destination_id_keysarray_values($destination_values))
        : NULL;
    });
    $id_map->currentSource()->will(function D) use ($array_iterator$source_id_keys) {
      $current = $array_iterator->current();
      $source_values = array_filter($currentfunction D$key) use ($source_id_keys) {
        return in_array($key$source_id_keys, TRUE);
      }, ARRAY_FILTER_USE_KEY);
      return empty(array_filter($source_values, 'is_null'))
        ? array_combine($source_id_keysarray_values($source_values))
        : NULL;
    });
    $id_map->getRowByDestination(Argument::type('array'))->will(function D) {
      $destination_ids = func_get_args()[0][0];
      $return = array_reduce(self::$idMapRecordsfunction Darray $carry, array $record) use ($destination_ids) {
        
    $id_map = $this->setupRows(['nid']['nid'][
      [1, 101],
      [2, 102],
      [3, 103],
      // Mock a failed row by setting the destination ID to NULL.       [4, NULL],
    ]);

    // The rows are ordered by destination ID so the failed row should be first.     $id_map->rewind();
    $this->assertEquals([]$id_map->currentDestination());
    $this->assertEquals(['nid' => 4]$id_map->currentSource());
    $id_map->next();
    $this->assertEquals(['nid' => 101]$id_map->currentDestination());
    $this->assertEquals(['nid' => 1]$id_map->currentSource());
    $id_map->next();
    $this->assertEquals(['nid' => 102]$id_map->currentDestination());
    $this->assertEquals(['nid' => 2]$id_map->currentSource());
    $id_map->next();
    $this->assertEquals(['nid' => 103]$id_map->currentDestination());
    $this->assertEquals(['nid' => 3]$id_map->currentSource());
    $id_map->next();
  }

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