function entity_translation_entity_info_alter in Entity Translation 7
Implements hook_entity_info_alter().
File
- ./
entity_translation.module, line 184
Code
function entity_translation_entity_info_alter(&$entity_info) {
// Provide defaults for translation info.
foreach ($entity_info as $entity_type => $info) {
if (!isset($entity_info[$entity_type]['translation']['entity_translation'])) {
$entity_info[$entity_type]['translation']['entity_translation'] = array();
}
$et_info =& $entity_info[$entity_type]['translation']['entity_translation'];
// Every fieldable entity type must have a translation handler class and
// translation keys defined, no matter if it is enabled for translation or
// not. As a matter of fact we might need them to correctly switch field
// translatability when a field is shared across different entity types.
$et_info += array(
'class' => 'EntityTranslationDefaultHandler',
);
if (!isset($entity_info[$entity_type]['entity keys'])) {
$entity_info[$entity_type]['entity keys'] = array();
}
$entity_info[$entity_type]['entity keys'] += array(
'translations' => 'translations',
);
if (entity_translation_enabled($entity_type, NULL, TRUE)) {
$entity_info[$entity_type]['language callback'] = 'entity_translation_language';
// Process path schemes and fill-in defaults.
_entity_translation_process_path_schemes($entity_type, $et_info);
// Merge in default values for remaining keys.
$et_info += array(
'access callback' => 'entity_translation_tab_access',
'access arguments' => array(
$entity_type,
),
);
// Interpret a TRUE value for the 'edit form' key as the default value.
if (!isset($et_info['edit form']) || $et_info['edit form'] === TRUE) {
$et_info['edit form'] = $entity_type;
}
}
}
}