You are here

function term_merge_fields_with_foreign_key in Term Merge 7

Fetch all fields that have a foreign key to provided column.

Parameters

string $foreign_table: Name of the table for which to look among foreign keys of all the fields

string $foreign_column: Name of the column for which to look among foreign keys of all the fields

Return value

array Array of all fields that have the specified table and column within their foreign keys. Each of the fields array will be extended to include the following additional keys:

  • term_merge_field_column: (string) Name of the field column that holds foreign key to the provided table and column
2 calls to term_merge_fields_with_foreign_key()
term_merge_action in ./term_merge.module
Action function. Perform action "Term Merge".
term_merge_duplicates_form in ./term_merge.pages.inc
Generate 'term_merge_duplicates_form'.

File

./term_merge.module, line 848
Provide functionality for merging taxonomy terms one into another.

Code

function term_merge_fields_with_foreign_key($foreign_table, $foreign_column) {
  $fields = field_info_fields();
  $result = array();
  foreach ($fields as $field_name => $field_info) {
    foreach ($field_info['foreign keys'] as $foreign_key) {
      if ($foreign_key['table'] == $foreign_table) {
        $column = array_search($foreign_column, $foreign_key['columns']);
        if ($column) {
          $field_info['term_merge_field_column'] = $column;
          $result[] = $field_info;
        }
      }
    }
  }
  return $result;
}