mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #430 from halkyon/getallfields_fixes
MINOR Fixing use of deprecated getAllFields(), mark field as deprecated ...
This commit is contained in:
commit
13c9011082
@ -70,10 +70,10 @@ class DataDifferencer extends ViewableData {
|
||||
function diffedData() {
|
||||
if($this->fromRecord) {
|
||||
$diffed = clone $this->fromRecord;
|
||||
$fields = array_keys($diffed->getAllFields() + $this->toRecord->getAllFields());
|
||||
$fields = array_keys($diffed->toMap() + $this->toRecord->toMap());
|
||||
} else {
|
||||
$diffed = clone $this->toRecord;
|
||||
$fields = array_keys($this->toRecord->getAllFields());
|
||||
$fields = array_keys($this->toRecord->toMap());
|
||||
}
|
||||
|
||||
$hasOnes = $this->fromRecord->has_one();
|
||||
@ -144,10 +144,10 @@ class DataDifferencer extends ViewableData {
|
||||
|
||||
if($this->fromRecord) {
|
||||
$base = $this->fromRecord;
|
||||
$fields = array_keys($this->fromRecord->getAllFields());
|
||||
$fields = array_keys($this->fromRecord->toMap());
|
||||
} else {
|
||||
$base = $this->toRecord;
|
||||
$fields = array_keys($this->toRecord->getAllFields());
|
||||
$fields = array_keys($this->toRecord->toMap());
|
||||
}
|
||||
|
||||
foreach($fields as $field) {
|
||||
@ -190,13 +190,13 @@ class DataDifferencer extends ViewableData {
|
||||
*/
|
||||
function changedFieldNames() {
|
||||
$diffed = clone $this->fromRecord;
|
||||
$fields = array_keys($diffed->getAllFields());
|
||||
$fields = array_keys($diffed->toMap());
|
||||
|
||||
$changedFields = array();
|
||||
|
||||
foreach($fields as $field) {
|
||||
if(in_array($field, $this->ignoredFields)) continue;
|
||||
if($this->fromRecord->$field != $this->toRecord->$field) {
|
||||
if($this->fromRecord->$field != $this->toRecord->$field) {
|
||||
$changedFields[] = $field;
|
||||
}
|
||||
}
|
||||
|
@ -1982,6 +1982,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return array A map of field names to field values.
|
||||
*/
|
||||
public function getAllFields() {
|
||||
Deprecation::notice('3.0', 'Use toMap() instead.');
|
||||
return $this->toMap();
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ class DataObjectLazyLoadingTest extends SapphireTest {
|
||||
$parentTeam = $this->objFromFixture('DataObjectTest_Team', 'team1');
|
||||
$teams = DataObject::get('DataObjectTest_Team'); // query parent class
|
||||
$subteam1Lazy = $teams->find('ID', $subteam1->ID);
|
||||
$this->assertArrayNotHasKey('SubclassDatabaseField_Lazy', $subteam1Lazy->getAllFields());
|
||||
$this->assertArrayHasKey('SubclassDatabaseField', $subteam1Lazy->getAllFields());
|
||||
$this->assertArrayNotHasKey('SubclassDatabaseField_Lazy', $subteam1Lazy->toMap());
|
||||
$this->assertArrayHasKey('SubclassDatabaseField', $subteam1Lazy->toMap());
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
||||
}
|
||||
|
||||
$valueObject = Object::create_from_string($castConstructor, $fieldName);
|
||||
$valueObject->setValue($value, ($this->hasMethod('getAllFields') ? $this->getAllFields() : null));
|
||||
$valueObject->setValue($value, ($this->hasMethod('toMap') ? $this->toMap() : null));
|
||||
|
||||
$value = $valueObject;
|
||||
}
|
||||
@ -704,10 +704,10 @@ class ViewableData_Debugger extends ViewableData {
|
||||
|
||||
$debug .= '</ul>';
|
||||
|
||||
if($this->object->hasMethod('getAllFields')) {
|
||||
if($this->object->hasMethod('toMap')) {
|
||||
$debug .= "<b>Debugging Information: all fields available in '{$this->object->class}'</b><br/><ul>";
|
||||
|
||||
foreach($this->object->getAllFields() as $field => $value) {
|
||||
foreach($this->object->toMap() as $field => $value) {
|
||||
$debug .= "<li>\$$field</li>";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user