MigratePostRowSaveEvent example

$save = FALSE;
        }

        if ($save) {
          try {
            $this->getEventDispatcher()
              ->dispatch(new MigratePreRowSaveEvent($this->migration, $this->message, $row), MigrateEvents::PRE_ROW_SAVE);
            $destination_ids = $id_map->lookupDestinationIds($this->sourceIdValues);
            $destination_id_values = $destination_ids ? reset($destination_ids) : [];
            $destination_id_values = $destination->import($row$destination_id_values);
            $this->getEventDispatcher()
              ->dispatch(new MigratePostRowSaveEvent($this->migration, $this->message, $row$destination_id_values), MigrateEvents::POST_ROW_SAVE);
            if ($destination_id_values) {
              // We do not save an idMap entry for config.               if ($destination_id_values !== TRUE) {
                $id_map->saveIdMapping($row$destination_id_values$this->sourceRowStatus, $destination->rollbackAction());
              }
            }
            else {
              $id_map->saveIdMapping($row[], MigrateIdMapInterface::STATUS_FAILED);
              if (!$id_map->messageCount()) {
                $message = $this->t('New object was not saved, no error provided');
                $this->saveMessage($message);
                
/** * Tests getDestinationIdValues method. * * @covers ::__construct * @covers ::getDestinationIdValues */
  public function testGetDestinationIdValues() {
    $migration = $this->prophesize('\Drupal\migrate\Plugin\MigrationInterface')->reveal();
    $message_service = $this->prophesize('\Drupal\migrate\MigrateMessageInterface')->reveal();
    $row = $this->prophesize('\Drupal\migrate\Row')->reveal();
    $event = new MigratePostRowSaveEvent($migration$message_service$row[1, 2, 3]);
    $this->assertSame([1, 2, 3]$event->getDestinationIdValues());
  }

  /** * Tests getRow method. * * @covers ::__construct * @covers ::getRow */
  public function testGetRow() {
    $migration = $this->prophesize('\Drupal\migrate\Plugin\MigrationInterface')->reveal();
    
Home | Imprint | This part of the site doesn't use cookies.