Bridge with symfony/serializer

Refer to the official documentation on Symfony’s website.

This bridge provides a ways to (de)normalize items in batch job execution.

Denormalize item processor

This item processor will denormalize scalar items to an object, and return the denormalized version.

<?php

declare(strict_types=1);

use App\Entity\User;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Yokai\Batch\Bridge\Symfony\Serializer\DenormalizeItemProcessor;

/** @var DenormalizerInterface $serializer */

new DenormalizeItemProcessor(
    denormalizer: $serializer,
    type: User::class, // the expected class to instantiate
    context: [], // some extra context that will be provided during denormalization
);

Normalize item processor

This item processor will normalize each item and returns the normalized version.

<?php

declare(strict_types=1);

use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Yokai\Batch\Bridge\Symfony\Serializer\NormalizeItemProcessor;

/** @var DenormalizerInterface $serializer */

new NormalizeItemProcessor(
    normalizer: $serializer,
    format: 'json', // or any format supported by the serializer
    context: [], // some extra context that will be provided during normalization
);