mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Revert DataObject::validate to 3.1 method signature (protected)
This commit is contained in:
parent
d3d28c8632
commit
58cc3da8d8
@ -57,7 +57,7 @@
|
|||||||
* Refactor of database connectivity classes into separate components linked together through dependency injection
|
* Refactor of database connectivity classes into separate components linked together through dependency injection
|
||||||
* Refactor of `SQLQuery` into separate objects for each query type: `SQLQuery`, `SQLDelete`, `SQLUpdate` and `SQLInsert`
|
* Refactor of `SQLQuery` into separate objects for each query type: `SQLQuery`, `SQLDelete`, `SQLUpdate` and `SQLInsert`
|
||||||
* PDO is now a standard connector, and is available for all database interfaces
|
* PDO is now a standard connector, and is available for all database interfaces
|
||||||
* `DataObject::validate()` method visibility changed to public
|
* `DataObject::doValidate()` method visibility added to access `DataObject::validate` externally
|
||||||
* `NumericField` now uses HTML5 "number" type instead of "text"
|
* `NumericField` now uses HTML5 "number" type instead of "text"
|
||||||
* `UploadField` "Select from files" shows files in all folders by default
|
* `UploadField` "Select from files" shows files in all folders by default
|
||||||
* `UploadField` won't display an overwrite warning unless `Upload::replaceFile` is true
|
* `UploadField` won't display an overwrite warning unless `Upload::replaceFile` is true
|
||||||
@ -196,24 +196,6 @@
|
|||||||
|
|
||||||
## Upgrading Notes
|
## Upgrading Notes
|
||||||
|
|
||||||
### 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() {
|
|
||||||
...
|
|
||||||
}
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### UploadField "Select from files" shows files in all folders by default
|
### UploadField "Select from files" shows files in all folders by default
|
||||||
|
|
||||||
In order to list files in a single folder by default (previous default behaviour),
|
In order to list files in a single folder by default (previous default behaviour),
|
||||||
|
@ -913,7 +913,7 @@ class File extends DataObject {
|
|||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
if($this->config()->apply_restrictions_to_admin || !Permission::check('ADMIN')) {
|
if($this->config()->apply_restrictions_to_admin || !Permission::check('ADMIN')) {
|
||||||
// Extension validation
|
// Extension validation
|
||||||
// TODO Merge this with Upload_Validator
|
// TODO Merge this with Upload_Validator
|
||||||
|
@ -326,7 +326,7 @@ class Folder extends File {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
return new ValidationResult(true);
|
return new ValidationResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +919,7 @@ class FormField extends RequestHandler {
|
|||||||
* Validation method each {@link FormField} subclass should implement,
|
* Validation method each {@link FormField} subclass should implement,
|
||||||
* determining whether the field is valid or not based on the value.
|
* determining whether the field is valid or not based on the value.
|
||||||
*
|
*
|
||||||
* @param Validator
|
* @param Validator $validator
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function validate($validator) {
|
public function validate($validator) {
|
||||||
|
@ -1063,12 +1063,22 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @see {@link ValidationResult}
|
* @see {@link ValidationResult}
|
||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
$result = ValidationResult::create();
|
$result = ValidationResult::create();
|
||||||
$this->extend('validate', $result);
|
$this->extend('validate', $result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public accessor for {@see DataObject::validate()}
|
||||||
|
*
|
||||||
|
* @return ValidationResult
|
||||||
|
*/
|
||||||
|
public function doValidate() {
|
||||||
|
// validate will be public in 4.0
|
||||||
|
return $this->validate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler called before writing to the database.
|
* Event handler called before writing to the database.
|
||||||
* You can overload this to clean up or otherwise process data before writing it to the
|
* You can overload this to clean up or otherwise process data before writing it to the
|
||||||
|
@ -336,7 +336,7 @@ class Group extends DataObject {
|
|||||||
$this->setField("Code", Convert::raw2url($val));
|
$this->setField("Code", Convert::raw2url($val));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
// Check if the new group hierarchy would add certain "privileged permissions",
|
// Check if the new group hierarchy would add certain "privileged permissions",
|
||||||
|
@ -1487,7 +1487,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
/**
|
/**
|
||||||
* Validate this member object.
|
* Validate this member object.
|
||||||
*/
|
*/
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
$valid = parent::validate();
|
$valid = parent::validate();
|
||||||
|
|
||||||
if(!$this->ID || $this->isChanged('Password')) {
|
if(!$this->ID || $this->isChanged('Password')) {
|
||||||
|
@ -20,7 +20,7 @@ class PermissionRoleCode extends DataObject {
|
|||||||
"Role" => "PermissionRole",
|
"Role" => "PermissionRole",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function validate() {
|
protected 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.
|
||||||
|
@ -103,18 +103,18 @@ class FileTest extends SapphireTest {
|
|||||||
|
|
||||||
// Invalid ext
|
// Invalid ext
|
||||||
$file->Name = 'asdf.php';
|
$file->Name = 'asdf.php';
|
||||||
$v = $file->validate();
|
$v = $file->doValidate();
|
||||||
$this->assertFalse($v->valid());
|
$this->assertFalse($v->valid());
|
||||||
$this->assertContains('Extension is not allowed', $v->message());
|
$this->assertContains('Extension is not allowed', $v->message());
|
||||||
|
|
||||||
// Valid ext
|
// Valid ext
|
||||||
$file->Name = 'asdf.txt';
|
$file->Name = 'asdf.txt';
|
||||||
$v = $file->validate();
|
$v = $file->doValidate();
|
||||||
$this->assertTrue($v->valid());
|
$this->assertTrue($v->valid());
|
||||||
|
|
||||||
// Capital extension is valid as well
|
// Capital extension is valid as well
|
||||||
$file->Name = 'asdf.TXT';
|
$file->Name = 'asdf.TXT';
|
||||||
$v = $file->validate();
|
$v = $file->doValidate();
|
||||||
$this->assertTrue($v->valid());
|
$this->assertTrue($v->valid());
|
||||||
|
|
||||||
Config::inst()->remove('File', 'allowed_extensions');
|
Config::inst()->remove('File', 'allowed_extensions');
|
||||||
|
@ -1811,7 +1811,7 @@ class DataObjectTest_ValidatedObject extends DataObject implements TestOnly {
|
|||||||
'Name' => 'Varchar(50)'
|
'Name' => 'Varchar(50)'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function validate() {
|
protected 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