本文整理汇总了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;
}
}
}