You are here

protected function JuiceboxXmlField::loadFormatterData in Juicebox HTML5 Responsive Image Galleries 7.2

Load the Drupal data that's needed to initialize a field-based Juicebox gallery from scratch.

1 call to JuiceboxXmlField::loadFormatterData()
JuiceboxXmlField::getXml in plugins/JuiceboxXmlField.inc
Get the XML based on loaded data.

File

plugins/JuiceboxXmlField.inc, line 149
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

protected function loadFormatterData() {

  // Get the bundle details.
  $info = entity_get_info($this->entityType);
  if (empty($info['entity keys']['bundle'])) {
    $bundle = $this->entityType;
  }
  else {
    $bundle = $this->entity->{$info['entity keys']['bundle']};
  }

  // Get the instance and display details.
  $instance = field_info_instance($this->entityType, $this->fieldName, $bundle);
  if ($instance) {
    $display = field_get_display($instance, $this->displayName, $this->entity);
    if (isset($display['type']) && $display['type'] == 'juicebox_formatter') {
      $this->settings = $display['settings'];

      // We now have the same data available that the formatter plugin would
      // have.
      return;
    }
  }

  // If we got here there was a problem loading the data.
  throw new Exception(t('There was problem loading Drupal data for a field-based Juicebox gallery.'));
}