algolia / scout-extended

Scout Extended: The Full Power of Algolia in Laravel
https://www.algolia.com/doc/framework-integration/laravel/getting-started/introduction-to-scout-extended/
MIT License
393 stars 85 forks source link

chore: make class non-final #297

Closed DevinCodes closed 2 years ago

DevinCodes commented 2 years ago
Q A
Bug fix? no
New feature? no
BC breaks? no
Related Issue Fix #293

Describe your change

This removes the final keyword from the ObjectEncrypter class, so its behavior can be customized. Please note that we don't provide support when you decide to override this class.

mattdfloyd commented 2 years ago

It would seem that for this change to be really beneficial that the ObjectEncrypter would need to be resolved from the container. As is, extending this class doesn't have much benefit unless you also reimplement anywhere the class is called. If the ObjectEncrypter was resolved out of the container each time it is used, the developer would have full control over the functionality. In the end, this really may not be what is desired though.

Alternatively, another solution to possibly solve #293, and my use case, would be allowing the first part of the encrypted ObjectID to be configured. This way the developer nearly have full control of how the ObjectID is constructed.

This has a similar feel to me to how Laravel can configure morph maps to decouple values from their implementation. In the same way, we'd almost certainly need a map available at a global level so that decryption of the ObjectID and the Searhable model resolution could still work.

For my use case, I am looking into how to prevent the ObjectID from changing should the Model name ever change. Currently, if App\Models\Auto was renamed to App\Models\Automobile all analytics (I assume) would be lost for those search objects as the ObjectId would change from App\Models\Auto::1 to App\Models\Automobile::1.

LoganTFox commented 1 month ago

+1