Skip to content

Commit

Permalink
use NormalizerAwareInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
mtarld committed Jan 19, 2023
1 parent 7fe9fc1 commit 1974d3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Maker/MakeSerializerNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
Expand Down Expand Up @@ -59,6 +61,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
NormalizerInterface::class,
ObjectNormalizer::class,
CacheableSupportsMethodInterface::class,
NormalizerAwareInterface::class,
NormalizerAwareTrait::class,
]);

$generator->generateClass(
Expand Down
6 changes: 2 additions & 4 deletions src/Resources/skeleton/serializer/Normalizer.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

<?= $use_statements; ?>

class <?= $class_name ?> implements NormalizerInterface, CacheableSupportsMethodInterface
class <?= $class_name ?> implements NormalizerInterface, CacheableSupportsMethodInterface, NormalizerAwareInterface
{
public function __construct(private ObjectNormalizer $normalizer)
{
}
use NormalizerAwareTrait;

public function normalize($object, string $format = null, array $context = []): array
{
Expand Down

0 comments on commit 1974d3c

Please sign in to comment.