You are here

function i18n_get_object in Internationalization 7

Get object wrapper by object key.

Parameters

$type: The object type to load e.g. node_type, menu, taxonomy_term.

$key: The object key, can be an scalar or an array.

$object: Optional Drupal object or array. It will be autoloaded using the key if not present.

Return value

A fully-populated object wrapper.

1 call to i18n_get_object()
i18n_object in ./i18n.module
Get object wrapper.

File

./i18n.module, line 402
Internationalization (i18n) module.

Code

function i18n_get_object($type, $key, $object = NULL) {
  $cache =& drupal_static(__FUNCTION__);
  $index = is_array($key) ? implode(':', $key) : $key;
  if (!isset($cache[$type][$index])) {
    $class = i18n_object_info($type, 'class', 'i18n_object_wrapper');
    $object_wrapper = new $class($type, $key, $object);

    // Do not cache object with empty index.
    if (!empty($index)) {
      $cache[$type][$index] = $object_wrapper;
    }
  }
  else {
    $object_wrapper = $cache[$type][$index];
  }
  return $object_wrapper;
}