title: Use custom normalizer to modify class properties
body: <p>I have an entity with 2 properties, <code>name</code> and <code>photo</code>.  The <code>name</code> property is read from the database but I have to fill the <code>photo</code> property with some other information.</p>
  
  <p>I have followed the <strong><a href="https://api-platform.com/docs/core/content-negotiation#writing-a-custom-normalizer" rel="nofollow noreferrer">Writing a Custom Nomalizer</a></strong> tutorial from the docs and I have made my custom normalizer:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Serializer;
  
  use App\Entity\Style;
  use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  
  final class StyleNormalizer implements NormalizerInterface, DenormalizerInterface
  {
      private $normalizer;
  
      private $uploaderHelper;
  
      public function __construct(NormalizerInterface $normalizer, UploaderHelper $uploaderHelper)
      {
          if (!$normalizer instanceof DenormalizerInterface) {
              throw new \InvalidArgumentException('The normalizer must implement the DenormalizerInterface');
          }
  
          $this-&gt;normalizer = $normalizer;
          $this-&gt;uploaderHelper = $uploaderHelper;
      }
  
      public function denormalize($data, $class, $format = null, array $context = [])
      {
          return $this-&gt;normalizer-&gt;denormalize($data, $class, $format, $context);
      }
  
      public function supportsDenormalization($data, $type, $format = null)
      {
          return $this-&gt;normalizer-&gt;supportsDenormalization($data, $type, $format);
      }
  
      public function normalize($object, $format = null, array $context = [])
      {
          if ($object instanceof Style) {
              $object-&gt;setPhoto('http://api-platform.com');
          }
  
          return $this-&gt;normalizer-&gt;normalize($object, $format, $context);
      }
  
      public function supportsNormalization($data, $format = null)
      {
          return $this-&gt;normalizer-&gt;supportsNormalization($data, $format);
      }
  }
  </code></pre>
  
  <p>But the <code>photo</code> property is not filled with the required information.</p>
  
  <p>After a little bit of debug I have found that the <code>supportsNormalization</code> method is executed two times (for each database element). If I print the <code>$data</code>variable, I got the entity <code>name</code> property the first time and the <code>photo</code> property with <code>null</code> value the second time. I never got the entire <code>Style</code> entity. Then the <code>supportsNormalitzation</code> method always returns <code>false</code>.</p>
  
  <p>How can I get the full <code>Style</code> entity and modify its properties?</p>
  
  <p>Thanks!</p>