Skip to content
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

Pass true to enableAnnotationMapping() #7

Merged
merged 6 commits into from Dec 30, 2021

Conversation

MartkCz
Copy link
Member

@MartkCz MartkCz commented Oct 8, 2021

Since symfony/validator 5.2: Not passing true as first argument to "Symfony\Component\Validator\ValidatorBuilder::enableAnnotationMapping" is deprecated. Pass true and call "addDefaultDoctrineAnnotationReader()" if you want to enable annotation mapping with Doctrine Annotations.

@jiripudil
Copy link
Member

Hello, thanks! IIRC the enableAnnotationMapping method used to accept an optional instance of annotations Reader. Omitting the argument in service definition meant that Nette DI would autowire a reader if it is registered (e.g. by nettrine/annotations).

I'd like to preserve that behaviour and from what I've found out I think it should be enough to add another setup call:

$validatorBuilder->addSetup('setDoctrineAnnotationReader');

Could you please add that?

@MartkCz
Copy link
Member Author

MartkCz commented Oct 15, 2021

@jiripudil enableAnnotationMapping can be used without doctrine annotation reader, so I moved it outside of condition

Fix failing test with?

if ($this->getContainerBuilder()->findByType(Reader::class)) {
  $validatorBuilder->addSetup('setDoctrineAnnotationReader');
} else {
  $validatorBuilder->addSetup('addDefaultDoctrineAnnotationReader');
}

@jiripudil
Copy link
Member

enableAnnotationMapping can be used without doctrine annotation reader, so I moved it outside of condition

👍

Fix failing test with?

Yes please :) I'd prefer if this code was in beforeCompile though, so that it does not depend on extension registration order.

@jiripudil
Copy link
Member

Brilliant, thanks! To fix the failing --prefer-lowest test, could you please bump the symfony/validator dependency to ^5.2? I believe that should be the final bit, then this is ready to merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants