mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API DataObject::validate() visibility changed to public (issue #1659)
DataObject::validate() is currently set to protected, but this means you can't call validate() from outside the context of itself unless you overload the method to use a public visibility and then call parent::validate() As it would turn out, most classes that overload this method already set the visibility to public, so it would make sense the parent matches that as well.
This commit is contained in:
parent
d5179adb01
commit
6fc9db6f0e
@ -3,7 +3,24 @@
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
* Minimum PHP version raised to 5.3.3
|
* Minimum PHP version raised to 5.3.3
|
||||||
|
* DataObject::validate() method visibility changed to public
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### DataObject::validate() method visibility changed to public
|
||||||
|
|
||||||
|
The visibility of `DataObject::validate()` has been changed from `protected` to `public`.
|
||||||
|
|
||||||
|
Any existing classes that currently set this as `protected` should be changed like in
|
||||||
|
this example:
|
||||||
|
|
||||||
|
::php
|
||||||
|
class MyDataClass extends DataObject {
|
||||||
|
...
|
||||||
|
public function validate() {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
@ -1015,7 +1015,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*
|
*
|
||||||
* @return A {@link ValidationResult} object
|
* @return A {@link ValidationResult} object
|
||||||
*/
|
*/
|
||||||
protected function validate() {
|
public function validate() {
|
||||||
$result = ValidationResult::create();
|
$result = ValidationResult::create();
|
||||||
$this->extend('validate', $result);
|
$this->extend('validate', $result);
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -14,7 +14,7 @@ class PermissionRoleCode extends DataObject {
|
|||||||
"Role" => "PermissionRole",
|
"Role" => "PermissionRole",
|
||||||
);
|
);
|
||||||
|
|
||||||
protected function validate() {
|
public function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
// Check that new code doesn't increase privileges, unless an admin is editing.
|
// Check that new code doesn't increase privileges, unless an admin is editing.
|
||||||
|
@ -1304,7 +1304,7 @@ class DataObjectTest_ValidatedObject extends DataObject implements TestOnly {
|
|||||||
'Name' => 'Varchar(50)'
|
'Name' => 'Varchar(50)'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected function validate() {
|
public function validate() {
|
||||||
if(!empty($this->Name)) {
|
if(!empty($this->Name)) {
|
||||||
return new ValidationResult();
|
return new ValidationResult();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user