本文整理匯總了PHP中ArrayData::toMap方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayData::toMap方法的具體用法?PHP ArrayData::toMap怎麽用?PHP ArrayData::toMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayData
的用法示例。
在下文中一共展示了ArrayData::toMap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetArray
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);
}
示例2: updateLocalFile
/**
* 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);
}
示例3: copyToLocalObject
/**
* 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;
}
}
}