本文整理汇总了PHP中EEM_Base::get_field_containing_related_model_name方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::get_field_containing_related_model_name方法的具体用法?PHP EEM_Base::get_field_containing_related_model_name怎么用?PHP EEM_Base::get_field_containing_related_model_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EEM_Base
的用法示例。
在下文中一共展示了EEM_Base::get_field_containing_related_model_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _replace_temp_ids_with_mappings
/**
* Using the $old_db_to_new_db_mapping array, replaces all the temporary IDs
* with their mapped real IDs. Eg, if importing from site A to B, the mapping
* file may indicate that the ID "my_event_id" maps to an actual event ID of 123.
* So this function searches for any event temp Ids called "my_event_id" and
* replaces them with 123.
* Also, if there is no temp ID for the INT foreign keys from another database,
* replaces them with 0 or the field's default.
* @param type $model_object_data
* @param EEM_Base $model
* @param type $old_db_to_new_db_mapping
* @param boolean $export_from_site_a_to_b
* @return array updated model object data with temp IDs removed
*/
protected function _replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b)
{
//if this model object's primary key is in the mapping, replace it
if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment() && isset($old_db_to_new_db_mapping[$model->get_this_model_name()]) && isset($old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]])) {
$model_object_data[$model->primary_key_name()] = $old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]];
}
try {
$model_name_field = $model->get_field_containing_related_model_name();
$models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
} catch (EE_Error $e) {
$model_name_field = NULL;
$models_pointed_to_by_model_name_field = array();
}
foreach ($model->field_settings(true) as $field_obj) {
if ($field_obj instanceof EE_Foreign_Key_Int_Field) {
$models_pointed_to = $field_obj->get_model_names_pointed_to();
$found_a_mapping = false;
foreach ($models_pointed_to as $model_pointed_to_by_fk) {
if ($model_name_field) {
$value_of_model_name_field = $model_object_data[$model_name_field->get_name()];
if ($value_of_model_name_field == $model_pointed_to_by_fk) {
$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in($model_object_data[$field_obj->get_name()], $model_pointed_to_by_fk, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
$found_a_mapping = true;
break;
}
} else {
$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in($model_object_data[$field_obj->get_name()], $model_pointed_to_by_fk, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
$found_a_mapping = true;
}
//once we've found a mapping for this field no need to continue
if ($found_a_mapping) {
break;
}
}
} else {
//it's a string foreign key (which we leave alone, because those are things
//like country names, which we'd really rather not make 2 USAs etc (we'd actually
//prefer to just update one)
//or it's just a regular value that ought to be replaced
}
}
//
if ($model instanceof EEM_Term_Taxonomy) {
$model_object_data = $this->_handle_split_term_ids($model_object_data);
}
return $model_object_data;
}