Closed timhuijser closed 8 years ago
Can you post an example of your custom yaml configuration file for image sizes ?
Is it really an issue to have this information duplicated ? From my experience, these kind of thing do not change a lot. You will lose a lot of time for this optimization with little benefit in my opinion.
If you already have all information mandatory for the crop validator in a service, you can inject it directly in the service by overriding the default one :
jb_fileupload.crop.validator:
class: "%jb_fileupload.image.crop.class%"
tags:
- { name: jb_fileuploader.validator, alias: Crop }
You can either completly override this validator service to inject your provider as an argument or create a custom compiler pass to add your provider as an argument in the default jb_fileupload.crop.validator
and override the class to change the implementation. I had a blog post on the last solution (http://blog.bouzekri.net/2015/02/02/surcharger-n-importe-quel-service-symfony/) but it is in french ...
Thank you for your fast reply! I think for now I will just duplicate the information, it's the easiest way. It was more an optimisation. Right now I'm diving into Symfony, I will return and try your suggestions when I'm more advanced ;). Thank you for your help!
Hi Jonathan,
Right now I'm trying to add dynamic validation of a cropped image. How can I extend the CropValidator or the AbstractImageValidator to achieve this?
The image sizes are managed in a separate yaml file and I would like to only declare them once, not twice, for a liip filter and the crop validation. I wrote a provider to retrieve the image sizes from the yaml file. I then should pass it to the configuration of the validator in some way.
Hope you can help!
Tim