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() {
|
function diffedData() {
|
||||||
if($this->fromRecord) {
|
if($this->fromRecord) {
|
||||||
$diffed = clone $this->fromRecord;
|
$diffed = clone $this->fromRecord;
|
||||||
$fields = array_keys($diffed->getAllFields() + $this->toRecord->getAllFields());
|
$fields = array_keys($diffed->toMap() + $this->toRecord->toMap());
|
||||||
} else {
|
} else {
|
||||||
$diffed = clone $this->toRecord;
|
$diffed = clone $this->toRecord;
|
||||||
$fields = array_keys($this->toRecord->getAllFields());
|
$fields = array_keys($this->toRecord->toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasOnes = $this->fromRecord->has_one();
|
$hasOnes = $this->fromRecord->has_one();
|
||||||
@ -144,10 +144,10 @@ class DataDifferencer extends ViewableData {
|
|||||||
|
|
||||||
if($this->fromRecord) {
|
if($this->fromRecord) {
|
||||||
$base = $this->fromRecord;
|
$base = $this->fromRecord;
|
||||||
$fields = array_keys($this->fromRecord->getAllFields());
|
$fields = array_keys($this->fromRecord->toMap());
|
||||||
} else {
|
} else {
|
||||||
$base = $this->toRecord;
|
$base = $this->toRecord;
|
||||||
$fields = array_keys($this->toRecord->getAllFields());
|
$fields = array_keys($this->toRecord->toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
@ -190,7 +190,7 @@ class DataDifferencer extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
function changedFieldNames() {
|
function changedFieldNames() {
|
||||||
$diffed = clone $this->fromRecord;
|
$diffed = clone $this->fromRecord;
|
||||||
$fields = array_keys($diffed->getAllFields());
|
$fields = array_keys($diffed->toMap());
|
||||||
|
|
||||||
$changedFields = array();
|
$changedFields = array();
|
||||||
|
|
||||||
|
@ -1982,6 +1982,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return array A map of field names to field values.
|
* @return array A map of field names to field values.
|
||||||
*/
|
*/
|
||||||
public function getAllFields() {
|
public function getAllFields() {
|
||||||
|
Deprecation::notice('3.0', 'Use toMap() instead.');
|
||||||
return $this->toMap();
|
return $this->toMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class DataObjectLazyLoadingTest extends SapphireTest {
|
|||||||
$parentTeam = $this->objFromFixture('DataObjectTest_Team', 'team1');
|
$parentTeam = $this->objFromFixture('DataObjectTest_Team', 'team1');
|
||||||
$teams = DataObject::get('DataObjectTest_Team'); // query parent class
|
$teams = DataObject::get('DataObjectTest_Team'); // query parent class
|
||||||
$subteam1Lazy = $teams->find('ID', $subteam1->ID);
|
$subteam1Lazy = $teams->find('ID', $subteam1->ID);
|
||||||
$this->assertArrayNotHasKey('SubclassDatabaseField_Lazy', $subteam1Lazy->getAllFields());
|
$this->assertArrayNotHasKey('SubclassDatabaseField_Lazy', $subteam1Lazy->toMap());
|
||||||
$this->assertArrayHasKey('SubclassDatabaseField', $subteam1Lazy->getAllFields());
|
$this->assertArrayHasKey('SubclassDatabaseField', $subteam1Lazy->toMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$valueObject = Object::create_from_string($castConstructor, $fieldName);
|
$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;
|
$value = $valueObject;
|
||||||
}
|
}
|
||||||
@ -704,10 +704,10 @@ class ViewableData_Debugger extends ViewableData {
|
|||||||
|
|
||||||
$debug .= '</ul>';
|
$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>";
|
$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>";
|
$debug .= "<li>\$$field</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user