You are here

function entity_background_load_background in Entity background 7

Loads background plugins.

Parameters

$entity_type: An entity type which background should be loaded.

$entity: An entity object which background should be loaded.

1 call to entity_background_load_background()
entity_background_entity_view in ./entity_background.module
Implements hook_entity_view().

File

./entity_background.module, line 48
Module file entity background.

Code

function entity_background_load_background($entity_type, $entity) {
  $function_name = 'handler';
  $function = entity_background_get_background_plugin_function($entity_type, $entity, $function_name);

  // The function exist.
  if (function_exists($function)) {
    $selector = entity_background_generate_selector($entity_type, $entity);

    // Get background field collection.
    $wrapper = entity_metadata_wrapper($entity_type, $entity);
    $field_collection = $wrapper->eb_background
      ->value();

    //
    $static =& drupal_static($function, array());

    // Decorate the entity with the selector just once.
    if (!isset($static[$selector])) {

      // Run the function.
      $function($selector, $field_collection);
      $static[$selector] = TRUE;
    }
  }
}