You are here

public function JuiceboxXmlField::__construct in Juicebox HTML5 Responsive Image Galleries 7.2

Constructor.

Parameters

array $id_args: An indexed array of arguments that describe this gallery (and make up its XML URL). This information uniquely identifies the gallery and contains all the descriptive data needed to load it.

File

plugins/JuiceboxXmlField.inc, line 41
Juicebox XML loader that's used to load (and build via loaded methods) the XML associated with a Drupal field formatter plugin.

Class

JuiceboxXmlField
Class to load and build the XML associated with a Drupal field formatter plugin.

Code

public function __construct($id_args) {

  // We need 5 data sources to build a file-based gallery (the type along
  // with 4 identifiers for the field data).
  if (empty($id_args) || count($id_args) < 5) {
    throw new Exception(t('Cannot initiate field-based Juicebox XML due to insufficient ID args.'));
  }

  // Set data sources as properties.
  $this->idArgs = $id_args;
  $this->entityType = $id_args[1];
  $this->entityId = $id_args[2];
  $this->fieldName = $id_args[3];
  $this->displayName = $id_args[4];

  // Grab the loaded entity as well (typically from static cache).
  $entities = entity_load($this->entityType, array(
    $this->entityId,
  ));
  $this->entity = reset($entities);
}