From 9043526fd5eb102b13aaaa7b27a9c1798ee32c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timothe=CC=81e=20Martin?= Date: Sat, 29 Nov 2014 13:26:20 +0100 Subject: [PATCH] [Validator] Add deprecated logs on addViolation() and addViolationAt() methods. --- .../Component/Validator/Context/ExecutionContext.php | 12 ++++++++++++ src/Symfony/Component/Validator/ExecutionContext.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 8934a42e62a7f..a26fd43bd0dce 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -183,6 +183,12 @@ public function setConstraint(Constraint $constraint) */ public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) { + trigger_error( + 'The parameters $invalidValue, $pluralization and $code are not supported anymore '. + 'as of Symfony 2.5 and will be removed in Symfony 3.0. Please use buildViolation() instead.', + E_USER_DEPRECATED + ); + // The parameters $invalidValue and following are ignored by the new // API, as they are not present in the new interface anymore. // You should use buildViolation() instead. @@ -310,6 +316,12 @@ public function getPropertyPath($subPath = '') */ public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) { + trigger_error( + 'The parameters $invalidValue, $pluralization and $code are not supported anymore '. + 'as of Symfony 2.5 and will be removed in Symfony 3.0. Please use buildViolation() instead.', + E_USER_DEPRECATED + ); + throw new BadMethodCallException( 'addViolationAt() is not supported anymore as of Symfony 2.5. '. 'Please use buildViolation() instead or enable the legacy mode.' diff --git a/src/Symfony/Component/Validator/ExecutionContext.php b/src/Symfony/Component/Validator/ExecutionContext.php index 31911b8d712c6..e78d10cbed647 100644 --- a/src/Symfony/Component/Validator/ExecutionContext.php +++ b/src/Symfony/Component/Validator/ExecutionContext.php @@ -92,6 +92,12 @@ public function __construct(GlobalExecutionContextInterface $globalContext, Tran */ public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null) { + trigger_error( + 'The parameters $invalidValue, $pluralization and $code are not supported anymore '. + 'as of Symfony 2.5 and will be removed in Symfony 3.0. Please use buildViolation() instead.', + E_USER_DEPRECATED + ); + if (null === $plural) { $translatedMessage = $this->translator->trans($message, $params, $this->translationDomain); } else { @@ -120,6 +126,12 @@ public function addViolation($message, array $params = array(), $invalidValue = */ public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) { + trigger_error( + 'The parameters $invalidValue, $pluralization and $code are not supported anymore '. + 'as of Symfony 2.5 and will be removed in Symfony 3.0. Please use buildViolation() instead.', + E_USER_DEPRECATED + ); + $this->globalContext->getViolations()->add(new ConstraintViolation( null === $plural ? $this->translator->trans($message, $parameters, $this->translationDomain)