Projet

Général

Profil

Paste
Télécharger (1,55 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / entity / tests / entity_test_i18n.module @ 7d7b5830

1
<?php
2

    
3
/**
4
 * @file
5
 * Entity-test i18n integration module via entity API i18n support.
6
 *
7
 * @see EntityDefaultI18nController
8
 */
9

    
10
/**
11
 * Implements hook_entity_info_alter().
12
 */
13
function entity_test_i18n_entity_info_alter(&$info) {
14
  // Enable i18n support via the entity API.
15
  $info['entity_test_type']['i18n controller class'] = 'EntityDefaultI18nStringController';
16
}
17

    
18
/**
19
 * Implements hook_entity_property_info_alter().
20
 */
21
function entity_test_i18n_entity_property_info_alter(&$info) {
22
  // Mark some properties as translatable, but also denote that translation
23
  // works with i18n_string.
24
  foreach (array('label') as $name) {
25
    $info['entity_test_type']['properties'][$name]['translatable'] = TRUE;
26
    $info['entity_test_type']['properties'][$name]['i18n string'] = TRUE;
27
  }
28
}
29

    
30
/**
31
 * Implements hook_{entity_test_type}_insert().
32
 */
33
function entity_test_i18n_entity_test_type_insert($test_type) {
34
  i18n_string_object_update('entity_test_type', $test_type);
35
}
36

    
37
/**
38
 * Implements hook_{entity_test_type}_update().
39
 */
40
function entity_test_i18n_entity_test_type_update($test_type) {
41
  // Account for name changes.
42
  if ($test_type->original->name != $test_type->name) {
43
    i18n_string_update_context("entity_test:entity_test_type:{$test_type->original->name}:*", "entity_test:entity_test_type:{$test_type->name}:*");
44
  }
45
  i18n_string_object_update('entity_test_type', $test_type);
46
}
47

    
48
/**
49
 * Implements hook_{entity_test_type}_delete().
50
 */
51
function entity_test_i18n_entity_test_type_delete($test_type) {
52
  i18n_string_object_remove('entity_test_type', $test_type);
53
}