You are here

function biblio_wrapper in Bibliography Module 7.2

Helper function to get a wrapper object, built by the Entity API, to help ease the pain of getting/setting field data. Fields for entities can be get and set using the following syntax: @example // set biblio field data (in this case, the title); $wrapper = biblio_wrapper($biblio, 'biblio') $wrapper->biblio_title->set('My Special Publication'); // get biblio field data $title = $wrapper->biblio_title->value();

Parameters

object $entity standard entity object - $biblio, $contributor, etc.:

string $entity_type biblio, biblio_contributor: Defaults to 'biblio'

Return value

object A fully structured entity wrapper built by the Entity API

30 calls to biblio_wrapper()
biblio_bibtex_entity_load in modules/bibtexParse/biblio_bibtex.module
Implements hook_entity_load().
biblio_category_section in includes/biblio.pages.inc
biblio_contextObject in includes/biblio.util.inc
biblio_contributor_page_view in ./biblio.module
Displays a biblio contributor; Hands data off to the Field API
biblio_contributor_pre_save in includes/biblio.contributors.inc
Perform actions to a contributor object before saving

... See full list

File

./biblio.module, line 2803

Code

function biblio_wrapper($entity, $entity_type = 'biblio') {
  $entity_types = biblio_entities();
  if (!in_array($entity_type, $entity_types)) {

    // We're not dealing with one of biblio's entity types
    $info = entity_get_info($entity_type);
    if (empty($info)) {

      // We're not even dealing with a real entity type.
      throw new Exception('Invalid entity type: ' . $entity_type);
    }
  }
  return entity_metadata_wrapper($entity_type, $entity);
}