-
Notifications
You must be signed in to change notification settings - Fork 70
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
[Bug] Context Is Lost On Aggregation #286
Comments
Thanks for this @kiler129, could this add some side-effects on people already using the search bundle (with this bug) ? |
@nunomaduro Basically no custom normalizers configured to support Algolia-related serialization will be invoked. Imagine an aggregator with such definition: public static function getEntities()
{
return [
Post::class,
Article::class
];
} Then you have such normalizer: class RandomNormalizer implements NormalizerInterface
{
public function normalize($object, $format = null, array $context = [])
{
//... some logic
}
public function supportsNormalization($data, $format = null)
{
dump('Object type: ' . \get_class($data));
dump('Format: ' . $format);
dump('--');
return $format === Searchable::NORMALIZATION_FORMAT && $data instanceof Post;
}
} WITHOUT my fix the condition in
WITH my fix:
...and this is just Essentially aggregators, without the fix, makes impossible to use any custom normalizers only for Algolia on aggregated entities (since format & context is only passed for aggregator itself, not for inner entities). |
#286: Carry over normalization context on aggregation
Description
While working on #283 implementation I discovered sometimes context is lost. I was able to track it down to these lines:
search-bundle/src/Entity/Aggregator.php
Lines 89 to 92 in d506f84
Is it intentional that format and other options (e.g. serialization groups) are ignored on this
normalize()
call? IMHO the code should NOT ignore them, since it will break custom normalizers.The text was updated successfully, but these errors were encountered: