function field_collection_entity_translation_delete in Field collection 7
Implements hook_entity_translation_delete().
File
- ./
field_collection.module, line 2132 - Module implementing field collection field type.
Code
function field_collection_entity_translation_delete($entity_type, $entity, $langcode) {
if (field_collection_item_is_translatable()) {
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
foreach (field_info_instances($entity_type, $bundle) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
if ($field['type'] === 'field_collection') {
$field_langcode = field_is_translatable($entity_type, $field) ? $langcode : LANGUAGE_NONE;
if (!empty($entity->{$field_name}[$field_langcode])) {
foreach ($entity->{$field_name}[$field_langcode] as $delta => $item) {
$field_collection_item = field_collection_field_get_entity($item);
$handler = entity_translation_get_handler('field_collection_item', $field_collection_item);
$translations = $handler
->getTranslations();
if (isset($translations->data[$langcode])) {
$handler
->removeTranslation($langcode);
$field_collection_item
->save(TRUE);
}
}
}
}
}
}
}