Skip to content

Add config example for class_serializers #329

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
Apr 9, 2020
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,31 @@ final class SentryCustomizationCompilerPass implements CompilerPassInterface
}
```

#### Custom serializers

The option class_serializers can be used to send customized objects serialization.
```yml
sentry:
options:
class_serializers:
YourValueObject: '@ValueObjectSerializer'
```

Several serializers can be added and the serializable check is done using **instanceof**. The serializer must implements the `__invoke` method returning an **array** with the information to send to sentry (class name is always sent).

Serializer example:
```php
final class ValueObjectSerializer
{
public function __invoke(YourValueObject $vo): array
{
return [
'value' => $vo->value()
];
}
}
```

[Last stable image]: https://poser.pugx.org/sentry/sentry-symfony/version.svg
[Packagist link]: https://packagist.org/packages/sentry/sentry-symfony
[Travis Build Status]: http://travis-ci.org/getsentry/sentry-symfony
Expand Down