-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Error when injecting object_repository and object_manager to UniqueObject validator annotation #585
Comments
You need to make sure that your form factory comes from the right service manager. If you inspect it via debugger (sorry, that's the only sensible way to do it), you will probably see that none of your factories are in it. |
I tried to do this using Xdebug but not sure I succeeded. Here's the output:
@Ocramius does this provide any clue as to which service manager is being used or the change needed to the factory config? |
It's not using your factories. |
Yes, I see. I tried to create a custom factory as below:
Then mapped this in Module.php:
However it still does not seem to use it (error and stack trace same as before). Am I on the right track? Is there some further configuration needed? |
Who created that annotation builder? |
It's part of the
|
@vvaswani that obviously breaks the entire dependency injection chain ;-) |
Yes, I think I see the issue now. But is there a better approach you can suggest, or a sample you can point me to that uses this validator with the annotation builder? Or, what's the correct way to accomplish this? |
If done manually, you'd have to call Something like this (if I remember correctly): $builder = new AnnotationBuilder();
$builder->setFormFactory(new Factory($container->get(FormElementManager::class))); Meanwhile, closing here: this is not a bug in DoctrineModule. |
@Ocramius , thanks for the tip! An update that I tried this:
Threw an immediate exception as
However this simply ended up back at the original error/stack trace. When I dump I did however manage to get it working through another approach, which I acknowledge is very hack-y. I removed the annotation in the entity and instantiated/attached the
Wish there was a better way but it gets the job done! Look forward to any suggestions to improve. |
Urgh, that's really ugly, and defeats the point of even using the builder. Don't know if this is the current approach, but see these related questions/issues (did a quick search)
|
I think I have similar problem with Fieldset - configured factories in
I want to add this |
I am trying to use the UniqueObject validator annotation in an entity but am unable to do so. This is in a ZF3 app. I see the error below
Not sure why it says "none given" as the array is present in the service config, see below.
Annotation:
Module.php:
I also tried placing this in getValidatorConfig and getFormElementsConfig as suggested in #289 , no luck. Please let me know how to make this work. I'll also add this info to the docs via a PR once it's working.
The text was updated successfully, but these errors were encountered: