function entity_metadata_wrapper

cis7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())
cle7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())
elmsmedia7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())
icor7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())
meedjum_blog7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())
mooc7 entity.module entity_metadata_wrapper($type, $data = NULL, array $info = array())

Returns a property wrapper for the given data.

If an entity is wrapped, the wrapper can be used to retrieve further wrappers for the entitity properties. For that the wrapper support chaining, e.g. you can use a node wrapper to get the node authors mail address:

  echo $wrappedNode->author->mail->value();

Parameters

$type: The type of the passed data.

$data: The data to wrap. It may be set to NULL, so the wrapper can be used without any data for getting information about properties.

$info: (optional) Specify additional information for the passed data:

  • langcode: (optional) If the data is language specific, its langauge code. Defaults to NULL, what means language neutral.
  • bundle: (optional) If an entity is wrapped but not passed, use this key to specify the bundle to return a wrapper for.
  • property info: (optional) May be used to use a wrapper with an arbitrary data structure (type 'struct'). Use this key for specifying info about properties in the same structure as used by hook_entity_property_info().
  • property info alter: (optional) A callback for altering the property info before it is utilized by the wrapper.
  • property defaults: (optional) An array of defaults for the info of each property of the wrapped data item.

Return value

EntityMetadataWrapper Dependend on the passed data the right wrapper is returned.

59 calls to entity_metadata_wrapper()
editableviews_entity_form_submit_build_values in sites/all/modules/ulmus/editableviews/editableviews.module
Form submit handler the first: build entities from field values.
editableviews_entity_form_submit_save in sites/all/modules/ulmus/editableviews/editableviews.module
Form submit handler the second: save entities.
editableviews_handler_field_entity_metadata_property::edit_form in sites/all/modules/ulmus/editableviews/handlers/editableviews_handler_field_entity_metadata_property.inc
Add the edit form for the field.
editableviews_handler_field_entity_metadata_property::edit_form_submit in sites/all/modules/ulmus/editableviews/handlers/editableviews_handler_field_entity_metadata_property.inc
Handle the form submission for this field's form element.
editableviews_handler_field_entity_metadata_property::edit_form_validate in sites/all/modules/ulmus/editableviews/handlers/editableviews_handler_field_entity_metadata_property.inc
Handle the form validation for this field's form element.

... See full list

File

sites/all/modules/ulmus/entity/entity.module, line 1403
Module file for the entity API.

Code

function entity_metadata_wrapper($type, $data = NULL, array $info = array()) {
  if ($type == 'entity' || (($entity_info = entity_get_info()) && isset($entity_info[$type]))) {
    // If the passed entity is the global $user, we load the user object by only
    // passing on the user id. The global user is not a fully loaded entity.
    if ($type == 'user' && is_object($data) && $data == $GLOBALS['user']) {
      $data = $data->uid;
    }
    return new EntityDrupalWrapper($type, $data, $info);
  }
  elseif ($type == 'list' || entity_property_list_extract_type($type)) {
    return new EntityListWrapper($type, $data, $info);
  }
  elseif (isset($info['property info'])) {
    return new EntityStructureWrapper($type, $data, $info);
  }
  else {
    return new EntityValueWrapper($type, $data, $info);
  }
}
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.