out example

foreach ($this->reader->read($config$resource$offset) as $row) {
            $event = new ImportExportBeforeImportRowEvent($row$config$context);
            $this->eventDispatcher->dispatch($event);
            $row = $event->getRow();

            // empty csv lines were already skipped by the reader.             // defaults are added to the raw csv row             $this->addUserDefaults($row$config);

            $record = [];
            foreach ($this->pipe->out($config$row) as $key => $value) {
                $record[$key] = $value;
            }

            if (empty($record)) {
                continue;
            }

            $result = null;
            $this->failedWriteCommands = null;

            if ($this->logEntity->getActivity() === ImportExportLogEntity::ACTIVITY_DRYRUN) {
                
yield from $generator;
    }

    public function out(Config $config, iterable $record): iterable
    {
        $pipes = array_reverse($this->chain);

        $generator = $record;

        foreach ($pipes as $pipe) {
            $generator = $pipe->out($config$generator);
        }

        yield from $generator;
    }
}
public function testEmptyMapping(): void
    {
        $mapping = [];
        $keyMappingPipe = new KeyMappingPipe($mapping, true);

        $config = new Config($mapping[][]);
        $pipeInResult = $keyMappingPipe->in($config['foo' => 'bar']);
        static::assertInstanceOf(\Traversable::class$pipeInResult);
        $actualOutput = iterator_to_array($pipeInResult);
        static::assertEmpty($actualOutput);

        $pipeOutResult = $keyMappingPipe->out($config['foo' => 'bar']);
        static::assertInstanceOf(\Traversable::class$pipeOutResult);
        $actualOutput = iterator_to_array($pipeOutResult);
        static::assertEmpty($actualOutput);
    }

    /** * @return array<array{input: array<string, mixed>, expectedOutput: array<string, mixed>}> */
    public static function simpleMappingProvider(): array
    {
        return [
            [

        $product->setUniqueIdentifier($id);

        $result = iterator_to_array($entityPipe->in($config$product->jsonSerialize()));

        static::assertSame($product->getId()$result['id']);
        static::assertSame($product->getTranslations()->first()->getName()$result['translations']['DEFAULT']['name']);
        static::assertSame((string) $product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame('1', $result['active']);

        $result = iterator_to_array($entityPipe->out($config$result));

        static::assertSame($product->getId()$result['id']);
        static::assertSame($product->getTranslations()->first()->getName()$result['translations'][Defaults::LANGUAGE_SYSTEM]['name']);
        static::assertSame($product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame($product->getActive()$result['active']);
    }
}
$this->assertSame($config$c);

                    $record = \is_array($record) ? $record : iterator_to_array($record);
                    $this->assertSame($data$record);

                    $innerOutCalled = true;

                    yield from $record;
                }
            );

        $result = iterator_to_array($chainPipe->out($config$data));
        static::assertSame($data$result);
    }
}
$mappedMedia = iterator_to_array($pipeInResult);

        static::assertSame($media['id']$mappedMedia['id']);
        static::assertSame($media['mediaFolderId']$mappedMedia['folder_id']);
        static::assertSame($media['url']$mappedMedia['url']);
        static::assertSame($media['private']$mappedMedia['private']);
        static::assertSame($media['mediaType']$mappedMedia['type']);

        static::assertSame($mediaTranslations['alt']$mappedMedia['alt']);
        static::assertSame($mediaTranslations['title']$mappedMedia['title']);

        $pipeOutResult = $mappingPipe->out($config$mappedMedia);
        static::assertInstanceOf(\Traversable::class$pipeOutResult);
        $unmappedMedia = iterator_to_array($pipeOutResult);
        $unmappedMediaTranslations = $unmappedMedia['translations']['DEFAULT'];

        static::assertSame($media['id']$unmappedMedia['id']);
        static::assertSame($media['mediaFolderId']$unmappedMedia['mediaFolderId']);
        static::assertSame($media['url']$unmappedMedia['url']);
        static::assertSame($media['private']$unmappedMedia['private']);
        static::assertSame($media['mediaType']$unmappedMedia['mediaType']);

        static::assertSame($mediaTranslations['alt']$unmappedMediaTranslations['alt']);
        
Home | Imprint | This part of the site doesn't use cookies.