Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
plugin system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Feb 2014 at 15:27 UTC
Updated:
7 Feb 2015 at 12:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerWell, we still use the default factory here:
The described class is just for the symfony part of the constrains.
Comment #2
andypostI still think this needs more investigation, constraints could become more complex and better to inject their dependencies
Comment #3
xanoConstraintsManager uses ContainerFactory, and not ConstraintValidationFactory (which belongs to Symfony), so dependency injection works.
If this doesn't answer your question, then I'm afraid I don't know what you mean.
Comment #4
larowlanYes, constraint plugins can implement ContainerFactoryPluginInterface, but validators cannot.
See CommentNameConstraintValidator.
Also see #2403817: Feed entity validation misses form validation logic - the
protected function feedStorage()over there demonstrates that ContainerFactoryPluginInterface doesn't work for the validators.Comment #5
larowlanAnd an example/failing test
Comment #6
larowlanAnd a fix showing it working
Comment #8
larowlanAnd remove the comment that sent me here.
Comment #9
ParisLiakos commentedlooks great
Comment #10
larowlanbeta eval, issue update
Comment #11
dawehnerPassing along the plugin configuration/ID and definition is pointless afaik. Why do you not just use the ClassResolver?
Comment #12
dawehnerAdapted the code a bit.
Comment #13
larowlanNice
Comment #15
dawehnermeh.
Comment #17
dawehnerLet's fix it.
Comment #18
larowlanlet's do it
Comment #21
ParisLiakos commentedbetter :)
Comment #22
fagoThis looks good, however I'm unsure how people will know they can do it that way? Should we document it at the manager given #2195083: Add a dedicated @Constraint annotation class is not done yet.
Comment #24
larowlanrandom fails
Comment #26
alexpott2197029-17.patch no longer applies.
Comment #27
ParisLiakos commentedreroll
Comment #28
larowlanStraight reroll
Comment #29
alexpottI think being able to unit test validators cleanly reduces fragility and there is no disruption. Committed 5f7ec33 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.