-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Hackday][Validator] Add deprecated logs on addViolation() and addViolationAt() methods. #12714
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be removed here. This is a bad method call already |
||
|
||
throw new BadMethodCallException( | ||
'addViolationAt() is not supported anymore as of Symfony 2.5. '. | ||
'Please use buildViolation() instead or enable the legacy mode.' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be triggered only when they are passed explicitely (i.e. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this log is useful because the whole class and the interface are deprecated, as they were moved to the |
||
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 | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the whole method is deprecated, not only arguments |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
$this->globalContext->getViolations()->add(new ConstraintViolation( | ||
null === $plural | ||
? $this->translator->trans($message, $parameters, $this->translationDomain) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be triggered only if the user passes them explicitly (and we already have an exception in this case actually). Currently, you are triggering deprecation notices all the time when using the method, even in the new way