Skip to content

custom encoders interface signature #11439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

@OskarStark OskarStark Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to implements ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` interface
to implement ``Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface`` or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` accordingly.

Why the same interface twice?

and a . (Dot) is missing at the end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I found out by myself, Decoder and Encoder....



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

Expand Down