Skip to content

2.5 Validation API changes #4233

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

Merged
merged 10 commits into from
Oct 18, 2014
Prev Previous commit
Next Next commit
Minor tweaks and a missing location thanks to xabbuh and WouterJ
  • Loading branch information
weaverryan committed Oct 2, 2014
commit 94fc520c79839c9dfa3b06abcd8f5bf703ace561
7 changes: 6 additions & 1 deletion cookbook/bundles/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,15 @@ there are 3 modes, which the user can configure in their project:

As a bundle author, you'll want to support *both* API's, since some users
may still be using the 2.4 API. Specifically, if your bundle adds a violation
directly to the :class:`Symfony\Component\Validator\Context\ExecutionContext`
directly to the :class:`Symfony\\Component\\Validator\\Context\\ExecutionContext`
(e.g. like in a custom validation constraint), you'll need to check for which
API is being used. The following code, would work for *all* users::

use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
// ...

class ContainsAlphanumericValidator extends ConstraintValidator
{
public function validate($value, Constraint $constraint)
Expand Down
2 changes: 1 addition & 1 deletion cookbook/form/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ on other extensions. You need add those extensions to the factory object::
{
parent::setUp();

$validator = $this->getMock('\Symfony\Component\Validator\ValidatorInterface');
$validator = $this->getMock('\Symfony\Component\Validator\Validator\ValidatorInterface');
$validator->method('validate')->will($this->returnValue(new ConstraintViolationList()));

$this->factory = Forms::createFormFactoryBuilder()
Expand Down