-
Notifications
You must be signed in to change notification settings - Fork 518
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
Override Auto-Inject configuration for Entity #1146
Comments
What is the purpose of avoiding auto inject? |
To remove the extraneous calls when the subsequent collection of entities that have VIch auto-inject enabled is very large and the files or user-defined inject event listeners are not needed for that request. In my case, I have a listener that converts the legacy database blob file instances to Vich during the pre-inject event. |
Can't you override vich_uploader.file_injector with your own service? Then listen to pre-inject event and avoid injecting using your conditions. |
It would be nice if it came built-in to VichUploaderBundle, so that a custom service did not need to be implemented by others or across multiple Symfony applications. I can work on a pull request that doesn't cause a BC break to implement the changes, so that the override feature is available to everyone. The idea is to provide an intermediary from having to specify I consider it a bad practice to override another bundle's services with your own. |
I disagree. It's even mentioned in documentation
But this can happen with every part of a bundle you override. Anyway, feel free to propose a PR. |
Feature Request
Summary
There are certain circumstances where auto-inject is not required for a specific request.
For example listing of a Product versus displaying the Order or Invoice of a product.
When auto-inject is enabled, retrieving the Product association of the Order will automatically inject the image.
This occurs either as a lazy loaded association (
$order->getProducts()
) or when eager loaded through a JOIN ORM query.It would be nice, if there were a method to disable the auto-inject setting for an entity in specific request(s) or operation.
Which could be implemented as an annotation or as a service event override.
Example usage:
From what I understand, the only way to circumvent the auto-inject currently would be to instruct an ORM query to select partial on the affected entity. Which would result in needing to write several use-case queries and having to maintain the queries as the object changes instead of being able to rely solely on the associations and events.
The text was updated successfully, but these errors were encountered: