Skip to content

Commit

Permalink
custom encoders interface signature
Browse files Browse the repository at this point in the history
Fixes the documentation about encoders that was wrong.
Using `Symfony\Component\Serializer\Encoder\EncoderInterface` no `$context` parameter is passed to `supportsEncoding` method. YOu have to use the ContextAware version of it.
  • Loading branch information
PandaaAgency authored Apr 15, 2019
1 parent a60d8d4 commit 754a62b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions serializer/custom_encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create your own encoder that uses the
return Yaml::dump($data);
}

public function supportsEncoding($format, array $context = [])
public function supportsEncoding($format)
{
return 'yaml' === $format;
}
Expand All @@ -42,12 +42,18 @@ create your own encoder that uses the
return Yaml::parse($data);
}

public function supportsDecoding($format, array $context = [])
public function supportsDecoding($format)
{
return 'yaml' === $format;
}
}

.. tip::

If you need access to ``$context`` in your ``supportsDecoding`` or ``supportsEncoding`` method, make sure
to implements ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` interface


Registering it in your app
--------------------------

Expand Down

0 comments on commit 754a62b

Please sign in to comment.