You are here

function entity_i18n_controller in Entity API 7

Gets the i18n controller for a given entity type.

Return value

EntityDefaultI18nStringController|array|false If a type is given, the controller for the given entity type. Else an array of all enabled controllers keyed by entity type is returned.

3 calls to entity_i18n_controller()
entity_i18n_object_info in ./entity.i18n.inc
Implements hook_i18n_object_info().
entity_i18n_string_info in ./entity.i18n.inc
Implements hook_i18n_string_info().
entity_i18n_string_objects in ./entity.i18n.inc
Implements hook_i18n_string_objects().

File

./entity.i18n.inc, line 15
Internationalization (i18n) integration.

Code

function entity_i18n_controller($type = NULL) {
  $static =& drupal_static(__FUNCTION__);
  if (!isset($type)) {

    // Invoke the function for each type to ensure we have fully populated the
    // static variable.
    foreach (entity_get_info() as $entity_type => $info) {
      entity_i18n_controller($entity_type);
    }
    return array_filter($static);
  }
  if (!isset($static[$type])) {
    $info = entity_get_info($type);

    // Do not activate it by default. Modules have to explicitly enable it by
    // specifying EntityDefaultI18nStringController or their customization.
    $class = isset($info['i18n controller class']) ? $info['i18n controller class'] : FALSE;
    $static[$type] = $class ? new $class($type, $info) : FALSE;
  }
  return $static[$type];
}