function entity_language

cis7 common.inc entity_language($entity_type, $entity)
cle7 common.inc entity_language($entity_type, $entity)
elmsmedia7 common.inc entity_language($entity_type, $entity)
icor7 common.inc entity_language($entity_type, $entity)
meedjum_blog7 common.inc entity_language($entity_type, $entity)
mooc7 common.inc entity_language($entity_type, $entity)

Returns the language of an entity.

Parameters

$entity_type: The entity type; e.g., 'node' or 'user'.

$entity: The entity for which to get the language.

Return value

A valid language code or NULL if the entity has no language support.

30 calls to entity_language()
comment_form in modules/comment/comment.module
Generate the basic commenting form, for appending to a node or display on a separate page.
comment_submit in modules/comment/comment.module
Prepare a comment for submission.
entity_metadata_field_get_language in sites/all/modules/ulmus/entity/modules/callbacks.inc
Helper for determining the field language to be used.
file_entity_edit in sites/all/modules/ulmus/file_entity/file_entity.pages.inc
Page callback: Form constructor for the file edit form.
file_entity_search_execute in sites/all/modules/ulmus/file_entity/file_entity.module
Implements hook_search_execute().

... See full list

5 string references to 'entity_language'
entity_metadata_field_get_language in sites/all/modules/ulmus/entity/modules/callbacks.inc
Helper for determining the field language to be used.
file_entity_edit in sites/all/modules/ulmus/file_entity/file_entity.pages.inc
Page callback: Form constructor for the file edit form.
file_entity_search_execute in sites/all/modules/ulmus/file_entity/file_entity.module
Implements hook_search_execute().
pathauto_entity_language in sites/all/modules/ulmus/pathauto/pathauto.module
Returns the language code of the given entity.
path_form_file_entity_edit_alter in sites/all/modules/ulmus/file_entity/file_entity.module
Implements hook_form_FORM_ID_alter() for file_entity_edit() on behalf of path.module.

File

includes/common.inc, line 7967
Common functions that many Drupal modules will need to reference.

Code

function entity_language($entity_type, $entity) {
  $info = entity_get_info($entity_type);

  // Invoke the callback to get the language. If there is no callback, try to
  // get it from a property of the entity, otherwise NULL.
  if (isset($info['language callback']) && function_exists($info['language callback'])) {
    $langcode = $info['language callback']($entity_type, $entity);
  }
  elseif (!empty($info['entity keys']['language']) && isset($entity->{$info['entity keys']['language']})) {
    $langcode = $entity->{$info['entity keys']['language']};
  }
  else {
    // The value returned in D8 would be LANGUAGE_NONE, we cannot use it here to
    // preserve backward compatibility. In fact this function has been
    // introduced very late in the D7 life cycle, mainly as the proper default
    // for field_attach_form(). By returning LANGUAGE_NONE when no language
    // information is available, we would introduce a potentially BC-breaking
    // API change, since field_attach_form() defaults to the default language
    // instead of LANGUAGE_NONE. Moreover this allows us to distinguish between
    // entities that have no language specified from ones that do not have
    // language support at all.
    $langcode = NULL;
  }

  return $langcode;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.