Permalink
Browse files

MINOR Fixing use of deprecated getAllFields(), mark field as deprecat…

…ed properly.
  • Loading branch information...
1 parent 7f4c6e3 commit 1859070fa9311fb86c37875ca0932e6b6266de01 @halkyon halkyon committed May 10, 2012
Showing with 12 additions and 11 deletions.
  1. +6 −6 model/DataDifferencer.php
  2. +1 −0 model/DataObject.php
  3. +2 −2 tests/model/DataObjectLazyLoadingTest.php
  4. +3 −3 view/ViewableData.php
View
@@ -70,10 +70,10 @@ function ignoreFields($ignoredFields) {
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 @@ function ChangedFields() {
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 @@ function ChangedFields() {
*/
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;
}
}
View
@@ -1982,6 +1982,7 @@ public function getField($field) {
* @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 @@ function testLazyLoadedFieldsGetAllFields() {
$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());
}
}
View
@@ -374,7 +374,7 @@ public function obj($fieldName, $arguments = null, $forceReturnedObject = true,
}
$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 @@ public function forTemplate($field = null) {
$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>";
}

0 comments on commit 1859070

Please sign in to comment.