-
Notifications
You must be signed in to change notification settings - Fork 71
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
[3.0] Normalizers usage #139
Comments
OR, If I decide to go for 1 normalizer, how do I contextualize the information I want to give to Algolia ? The use case is depending who is consuming/ the context of the serializer, give more or less data to Algolia than for the other contexts. Stupid example: class FooNormalizer implements NormalizerInterface, SerializerAwareInterface
{
public function normalize($object, $format = null, array $context = [])
{
if ($isForAlgolia) {
return [
'isRead' => $object->isRead($this->tokenStorage->getToken()->getUser()),
'name' => $object->getTitle(),
];
}
return [
'id' => $object->getId(),
'status' => $object->getStatus(),
];
}
}
|
And also, how to mimic the |
Also, i'm really interesting in testing the v3, but my account has a lot of objects and I've a paying account, so can you do something to not consume my credits/quotas that'll be used for my production please ? (appId: HO2U66MC0P) @julienbourdeau |
@tristanbes Can you create a new free app in your Algolia dashboard and email me at [email protected]? I will add you some free quota ;) Thanks a lot for trying. About the normalizers, the package will loop through the normalizers in order and use the first one where the method The searchableEntity will call the class FooNormalizer implements NormalizerInterface, SerializerAwareInterface
{
public function normalize($object, $format = null, array $context = [])
{
if ('searchableArray' == $format) {
return [
'isRead' => $object->isRead($this->tokenStorage->getToken()->getUser()),
'name' => $object->getTitle(),
];
}
return [
'id' => $object->getId(),
'status' => $object->getStatus(),
];
}
} Please let me know how that worked for your and I'll add this in the doc. |
I believe I can close this one, please let me know if I missed something. :) |
Hello,
I seen that 3.x uses a new concept to serialize data based on the Symfony serializer which is a great move IMHO.
If I already have a set of normalizer for my objects, BUT i don't want them to be used for Algolia (and use the one I provide instead), is there a way to do this ?
Can I use the
normalizers
key to provide only "whitelisted" normalizers ?Also, in that case I will have 2 normalizer for 1 object
Foo
How can I ensure that my previous code still uses the
Normalizer
I wrote and not uses the one I wrote for Algolia service ?The text was updated successfully, but these errors were encountered: