function title_field_replacement_toggle in Title 7
Toggle field replacement for the given field.
Parameters
$entity_type: The name of the entity type.
$bundle: The bundle the legacy field belongs to.
$legacy_field: The name of the legacy field to be replaced.
5 calls to title_field_replacement_toggle()
- drush_title_upgrade_title_field in ./
title.drush.inc - Command callback for upgrade-title-field.
- TitleFieldReplacementTestCase::testFieldReplacementWorkflow in tests/
TitleFieldReplacementTestCase.test - Test field replacement API and workflow.
- TitleTranslationTestCase::setUp in tests/
TitleTranslationTestCase.test - Sets up a Drupal site for running functional and integration tests.
- title_field_attach_create_bundle in ./
title.module - Implements hook_field_attach_create_bundle().
- title_field_replacement_form_submit in ./
title.admin.inc - Process field replacement form submissions.
File
- ./
title.module, line 302
Code
function title_field_replacement_toggle($entity_type, $bundle, $legacy_field) {
$info = title_field_replacement_info($entity_type, $legacy_field);
if (!$info) {
return;
}
$field_name = $info['field']['field_name'];
$instance = field_info_instance($entity_type, $field_name, $bundle);
if (empty($instance)) {
$options = variable_get('title_' . $entity_type, array());
$field = field_info_field($field_name);
if (empty($field)) {
field_create_field($info['field']);
}
$info['instance']['entity_type'] = $entity_type;
$info['instance']['bundle'] = $bundle;
$info['instance']['settings']['hide_label']['page'] = isset($options['hide_label']['page']) ? $options['hide_label']['page'] : FALSE;
$info['instance']['settings']['hide_label']['entity'] = isset($options['hide_label']['entity']) ? $options['hide_label']['entity'] : FALSE;
field_create_instance($info['instance']);
return TRUE;
}
field_delete_instance($instance);
return FALSE;
}