public function testGetArray() { $originalDeprecation = Deprecation::dump_settings(); Deprecation::notification_version('2.4'); $array = array('Foo' => 'Foo', 'Bar' => 'Bar', 'Baz' => 'Baz'); $arrayData = new ArrayData($array); $this->assertEquals($arrayData->toMap(), $array); Deprecation::restore_settings($originalDeprecation); }
/** * Copy all non-relation fields from the remote object to the local object * * @param File $localObject * @param ArrayData $remoteObject */ protected function updateLocalFile(File $localObject, ArrayData $remoteObject) { foreach ($remoteObject->toMap() as $field => $value) { // Skip ID and class if (in_array($field, array('ClassName', 'ID'))) { continue; } // Skip obsolete fields if (preg_match('/^_obsolete.*/', $field)) { continue; } // Don't map relations if (preg_match('/(.+)ID$/', $field)) { continue; } $localObject->{$field} = $value; } // Save mapping $this->mapObjects($localObject, $remoteObject); }
/** * Copies relevant field values from the $remoteObject to the $localObject * * @param DataObject $localObject * @param ArrayData $remoteObject */ protected function copyToLocalObject(DataObject $localObject, ArrayData $remoteObject) { foreach ($remoteObject->toMap() as $field => $value) { // Skip ID and class if (in_array($field, array('ClassName', 'ID'))) { continue; } // Skip obsolete fields if (preg_match('/^_obsolete.*/', $field)) { continue; } // While updating map any relation field that we can if (preg_match('/(?<relation>.+)ID$/', $field, $matches)) { if ($value) { // Try to find local ID that corresponds to this relation $localID = $this->findMappedRelation($matches['relation'], $value); // Skip empty if ($localID) { $localObject->{$field} = $localID; } } } else { $localObject->{$field} = $value; } } }