Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Don't use deprecated functions in Callback.rst#4105
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The addViolationAt function is marked as deprecated and should be replaced by buildViolation according to the Symfony update guides.
xabbuh commentedAug 8, 2014
This should be merged into the 2.5 branch. |
xabbuh commentedAug 8, 2014
@Rootie Can you also update the call in |
stof commentedAug 8, 2014
Actually, the doc should show code compatible with both the 2.4 and 2.5 API. Otherwise bundle authors might not maintain compatibility with both (for projects, you can skip this need as you control which API is used). Seesymfony/symfony#11587 for the way it is done in Symfony |
xabbuh commentedAug 8, 2014
That's a valid point. But I think that could well be done in a new cookbook chapter. We can then add a reference to this entry here. @Rootie You would also have to add a |
stof commentedAug 8, 2014
Well, if you only show the 2.5 API here, I'm sure people will create bundles incompatible with one of the API. Symfony currently supports 3 validation APIs:
The default config is to use 2.5-BC for PHP 5.3.9+ and to use 2.4 for old 5.3 versions (we cannot switch automatically to the incompatible API). |
xabbuh commentedAug 8, 2014
Well, if you think it's not too hard, we should do that. I didn't dive that deep into the changes. Nonetheless, having a section explaining all differences in detail seems valuable to me. But that's out of scope of this pull request and#4094 also addresses that. |
xabbuh commentedAug 8, 2014
Just noticed: there's also an older pull request for this (#4056). |
weaverryan commentedAug 8, 2014
@stof Thank you very much for the detailed description - I was hoping someone could help us understand this. But wow, this is a bit nuts! :) To simplify things, we'll obviouslyonly be making changes to the 2.5+ version of the docs. 2.4+2.3 use the 2.4 API, so they'll stay the same. For 2.5+, I agree with Stof that we should show both. But instead of writing code that's truly compatible with everything, I think we should just show both with comments saying which is which: // If you're using the new 2.5 validation API (you probably are!)$context->buildViolation('This name sounds totally fake!') ->atPath('firstName') ->addViolation();// If you're using the old 2.4 validation API$context->addViolationAt('firstName','This name sounds totally fake!',array(),null); For a normal user, telling them to have an Thoughts? |
Rootie commentedAug 8, 2014
Meanwhile i also updated custom_constraint.rst and added a versionadded hint. To me having code that is already marked as deprecated in the referecne seems a little strange. |
stof commentedAug 12, 2014
@Rootie The 2.4 API is marked as deprecated. But given that it is still possible to have a project using the 2.4 API only (because the 2.5-bc API requires PHP 5.3.9+ while Symfony allows 5.3.3+), an open-source bundle must still be compatible with it. and yes, I agree we could keep the instanceof check to support both together in a cookbook article (but we should add a warning linking to it) |
weaverryan commentedAug 16, 2014
@Rootie Thanks for those tweaks. Can you also update the code to show the old and new syntax. See Stof's comment about it - wemust show the deprecated version because if you're not on at least PHP 5.3.9, then you can't easily upgrade your code to the 2.5 API (since the 2.5-BC API requires PHP 5.3.9+). Thanks! |
weaverryan commentedSep 16, 2014
…, weaverryan)This PR was merged into the 2.5 branch.Discussion----------2.5 Validation API changes| Q | A| ------------- | ---| Doc fix? | no| New docs? | yes| Applies to | 2.5| Fixed tickets |#4094Hi guys!This takes the work in#4056,#4105 and#4161 and extends it based on some feedback. Basically, the whole validation stuff is quite difficult, because:A) We want to show the non-deprecated methods so people use the new stuffB) We don't want to confuse users on the 2.4 API (even though this number of users should be very small, as it would require you to have started a project in the past and be using 5.3.9 and lower#4105 (comment))This solution is to show the new way, but always show the old way in comments. This would check of A and B in#4094.Thanks!Commits-------9874d8e [#4233][#4094] Making validateValue and validate changes94fc520 Minor tweaks and a missing location thanks to xabbuh and WouterJf97ba7a Fixes thanks to@xabbuh279d8d6 Adding a section about keeping BC in a re-usable bundle280440e Adding details about the 2.4 API as commentse658b56 added a versionadded comment to Callback.rst70c5ca1 Update custom_contraint.rst to meet the new 2.5 api5dfe499 Don't use deprecated functions in Callback.rstf4380ed Update Callback.rst042dcf9 Replace addViolationAt (deprecated) by buildViolation
The addViolationAt function is marked as deprecated and should be replaced by buildViolation according to the Symfony update guides.