You are here

class JuiceboxDisplayStyle in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/style/JuiceboxDisplayStyle.php \Drupal\juicebox\Plugin\views\style\JuiceboxDisplayStyle

Plugin implementation of the 'juicebox' display style.

Plugin annotation


@ViewsStyle(
  id = "juicebox",
  title = @Translation("Juicebox Gallery"),
  help = @Translation("Display rows as a Juicebox Gallery."),
  theme = "views_view_list",
  display_types = {"normal"}
)

Hierarchy

Expanded class hierarchy of JuiceboxDisplayStyle

File

src/Plugin/views/style/JuiceboxDisplayStyle.php, line 30

Namespace

Drupal\juicebox\Plugin\views\style
View source
class JuiceboxDisplayStyle extends StylePluginBase {

  /**
   * A Juicebox formatter service.
   *
   * @var \Drupal\juicebox\JuiceboxFormatterInterface
   */
  protected $juicebox;

  /**
   * A Drupal entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * A Drupal entity field manager service.
   *
   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
   */
  protected $entityFieldManager;

  /**
   * A Drupal string translation service.
   *
   * @var \Drupal\Core\StringTranslation\TranslationInterface
   */
  protected $stringTranslation;

  /**
   * A Symfony request object for the current request.
   *
   * @var \Symfony\Component\HttpFoundation\Request
   */
  protected $request;

  /**
   * {@inheritdoc}
   */
  protected $usesGrouping = FALSE;

  /**
   * {@inheritdoc}
   */
  protected $usesFields = TRUE;

  /**
   * {@inheritdoc}
   */
  protected $usesRowPlugin = FALSE;

  /**
   * {@inheritdoc}
   */
  protected $usesRowClass = FALSE;

  /**
   * {@inheritdoc}
   */
  protected $usesOptions = TRUE;

  /**
   * Factory to fetch required dependencies from container.
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

    // Create a new instance of the plugin. This also allows us to extract
    // services from the container and inject them into our plugin via its own
    // constructor as needed.
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'), $container
      ->get('entity_field.manager'), $container
      ->get('link_generator'), $container
      ->get('string_translation'), $container
      ->get('request_stack'), $container
      ->get('juicebox.formatter'));
  }

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, LinkGeneratorInterface $link_generator, TranslationInterface $translation, RequestStack $request_stack, JuiceboxFormatterInterface $juicebox) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
    $this->entityFieldManager = $entity_field_manager;
    $this->stringTranslation = $translation;
    $this->request = $request_stack
      ->getCurrentRequest();
    $this->juicebox = $juicebox;
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $library = $this->juicebox
      ->getLibrary();
    $base_settings = $this->juicebox
      ->confBaseOptions();

    // Structure the base settings in the "default" format that views wants.
    foreach ($base_settings as $setting => $value) {
      $base_settings_default[$setting] = [
        'default' => $value,
      ];
    }
    $options = array_merge($base_settings_default, [
      'image_field' => [
        'default' => '',
      ],
      // If the library supports multi-size we can default to that for the main
      // image, otherwise use the "medium" style.
      'image_field_style' => [
        'default' => !empty($library['version']) && !in_array('juicebox_multisize_image_style', $library['disallowed_conf']) ? 'juicebox_multisize' : 'juicebox_medium',
      ],
      'thumb_field' => [
        'default' => '',
      ],
      'thumb_field_style' => [
        'default' => 'juicebox_square_thumb',
      ],
      'title_field' => [
        'default' => '',
      ],
      'caption_field' => [
        'default' => '',
      ],
      'show_title' => [
        'default' => 0,
      ],
    ]);
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $settings = $this->options;

    // Get the active field options.
    $options = $this
      ->confGetFieldSources();
    $missing_field_warning = '';
    if (empty($options['field_options_images'])) {
      $missing_field_warning = $this
        ->t('<strong>You must add a field of type image, file or file ID to your view display before this value can be set.</strong><br/>');
    }

    // Add the view-specific elements.
    $form['image_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Image Source'),
      '#default_value' => $settings['image_field'],
      '#description' => $this
        ->t('The field source to use for each image in the gallery. Must be an image field, file field or a file ID. If using a multivalued field (*) only the <em>first</em> value from each entity will be used.'),
      '#suffix' => $missing_field_warning,
      '#options' => $options['field_options_images'],
      '#empty_option' => $this
        ->t('- Select -'),
    ];
    $form['thumb_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Thumbnail Source'),
      '#default_value' => $settings['thumb_field'],
      '#description' => $this
        ->t('The field source to use for each thumbnail in the gallery. Must be an image field, file field or a file ID. Typically you will choose the same value that was set in the "Image Source" option above.'),
      '#suffix' => $missing_field_warning,
      '#options' => $options['field_options_images'],
      '#empty_option' => $this
        ->t('- Select -'),
    ];
    $form['image_field_style'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Image Field Style'),
      '#default_value' => $settings['image_field_style'],
      '#description' => $this
        ->t('The style formatter for the image. Any formatting settings configured on the field itself will be ignored and this style setting will always be used.'),
      '#options' => $this->juicebox
        ->confBaseStylePresets(),
      '#empty_option' => $this
        ->t('None (original image)'),
    ];
    $form['thumb_field_style'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Thumbnail Field Style'),
      '#default_value' => $settings['thumb_field_style'],
      '#description' => $this
        ->t('The style formatter for the thumbnail. Any formatting settings configured on the field itself will be ignored and this style setting will always be used.'),
      '#options' => $this->juicebox
        ->confBaseStylePresets(FALSE),
      '#empty_option' => $this
        ->t('None (original image)'),
    ];
    $form['title_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Title Field'),
      '#default_value' => $settings['title_field'],
      '#description' => $this
        ->t("The view's field that should be used for the title of each image in the gallery. Any formatting settings configured on the field itself will be respected."),
      '#options' => $options['field_options'],
      '#empty_option' => $this
        ->t('None'),
    ];
    $form['caption_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Caption Field'),
      '#default_value' => $settings['caption_field'],
      '#description' => $this
        ->t("The view's field that should be used for the caption of each image in the gallery. Any formatting settings configured on the field itself will be respected."),
      '#options' => $options['field_options'],
      '#empty_option' => $this
        ->t('None'),
    ];
    $form['show_title'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Show Gallery Title'),
      '#default_value' => $settings['show_title'],
      '#description' => $this
        ->t('Show the view display title as the gallery title.'),
    ];

    // Add the common form elements.
    $form = $this->juicebox
      ->confBaseForm($form, $settings);

    // Add view-sepcific field options for the linkURL setting.
    $linkurl_field_options = [];
    foreach ($options['field_options'] as $field_key => $field_name) {
      $linkurl_field_options[$field_key] = $this
        ->t('Field') . ' - ' . $field_name;
    }
    $form['linkurl_source']['#description'] = $form['linkurl_source']['#description'] . '</br><strong>' . $this
      ->t('If using a field source it must render a properly formatted URL and nothing else.') . '</strong>';
    $form['linkurl_source']['#options'] = array_merge($form['linkurl_source']['#options'], $linkurl_field_options);
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    $element = [];
    $view = $this->view;
    $settings = $this->options;
    $display_name = isset($view->current_display) ? $view->current_display : 'default';
    $view_args = empty($view->args) ? [] : $view->args;

    // Generate xml details.
    $xml_route_info = [
      'route_name' => 'juicebox.xml_viewsstyle',
      'route_parameters' => [
        'viewName' => $view
          ->id(),
        'displayName' => $display_name,
      ],
      'options' => [
        'query' => $this
          ->argsToQuery() + $this->request->query
          ->all(),
      ],
    ];

    // If we are previewing the view in the admin interface any changes made
    // will not be propogated through to the XML until the view is saved. This
    // can be very confusing as the preview will appear to be broken, so we
    // simply hide the preview output.
    if ($this->request
      ->get('_route') == 'entity.view.preview_form') {
      $message = $this->stringTranslation
        ->translate("Juicebox galleries cannot be viewed as a live preview. Please save your view and visit the full page URL for this display to preview this gallery.");
      $this
        ->messenger()
        ->addWarning($message);
      return [
        '#markup' => $message,
      ];
    }

    // Try building the gallery and its XML.
    try {

      // Initialize the gallery.
      $gallery = $this->juicebox
        ->newGallery($xml_route_info['route_parameters']);

      // Build the gallery.
      $this
        ->buildGallery($gallery);

      // Build field-specific contextual links.
      $contextual = $this
        ->buildContextualLinks($xml_route_info);

      // Create a render array with the gallery markup.
      $element = $this->juicebox
        ->buildEmbed($gallery, $settings, $xml_route_info, TRUE, FALSE, $contextual);
    } catch (\Exception $e) {
      $message = 'Exception building Juicebox embed code for view: !message in %function (line %line of %file).';
      watchdog_exception('juicebox', $e, $message);
    }
    return $element;
  }

  /**
   * Build the gallery based on loaded Drupal views data.
   *
   * @param Drupal\juicebox\JuiceboxGalleryInterface $gallery
   *   An initialized Juicebox gallery object.
   */
  protected function buildGallery(JuiceboxGalleryInterface $gallery) {
    $view = $this->view;
    $settings = $this->options;

    // Populate $this->rendered_fields.
    $this
      ->renderFields($view->result);

    // Get all row image data in the format of Drupal file field items.
    $image_items = $thumb_items = $this
      ->getItems($settings['image_field']);
    if ($settings['image_field'] != $settings['thumb_field']) {
      $thumb_items = $this
        ->getItems($settings['thumb_field']);
    }

    // Iterate through each view row and calculate the gallery-specific details.
    foreach ($image_items as $row_index => $image_item) {

      // Make sure each main image has a thumb item.
      $thumb_item = !empty($thumb_items[$row_index]) ? $thumb_items[$row_index] : $image_item;

      // Calculate the source data that Juicebox requires.
      $src_data = $this->juicebox
        ->styleImageSrcData($image_item, $settings['image_field_style'], $thumb_item, $settings['thumb_field_style'], $settings);

      // Short-circut this iteration if skipping an incompatible file.
      if (!$src_data['juicebox_compatible'] && $settings['incompatible_file_action'] == 'skip') {
        continue;
      }

      // Check if the linkURL should be customized based on view settings.
      if (!empty($settings['linkurl_source']) && !empty($this->rendered_fields[$row_index][$settings['linkurl_source']])) {
        $src_data['linkURL'] = (string) $this->rendered_fields[$row_index][$settings['linkurl_source']];
      }

      // Set the image title.
      $title = '';

      // If we have an incompatible file the title may need special handeling.
      if (!$src_data['juicebox_compatible'] && $settings['incompatible_file_action'] == 'show_icon_and_link') {
        $anchor = !empty($image_item->description) ? $image_item->description : $image_item->filename;
        $title = $this->linkGenerator
          ->generate($anchor, Url::fromUri($src_data['linkURL']));
      }
      elseif (!empty($settings['title_field']) && !empty($this->rendered_fields[$row_index][$settings['title_field']])) {
        $title = (string) $this->rendered_fields[$row_index][$settings['title_field']];
      }

      // Set the image caption.
      $caption = '';
      if (!empty($settings['caption_field']) && !empty($this->rendered_fields[$row_index][$settings['caption_field']])) {
        $caption = (string) $this->rendered_fields[$row_index][$settings['caption_field']];
      }

      // Add this image to the gallery.
      $gallery
        ->addImage($src_data, $title, $caption);
    }
    if ($settings['show_title']) {
      $gallery
        ->addOption('gallerytitle', Html::escape($view
        ->getTitle()));
    }

    // Run common build tasks.
    $this->juicebox
      ->runCommonBuild($gallery, $settings, $view);
  }

  /**
   * Utility to build contextual links for a viewstyle-based gallery display.
   *
   * @param array $xml_route_info
   *   Associative array of route info used to generate the XML.
   *
   * @return array
   *   An associated array of calculated contextual link information.
   */
  protected function buildContextualLinks(array $xml_route_info) {
    $contextual = [];

    // Add a contextual link to view the XML. Note that we include any query
    // params as route paramaters. These won't be used in the actual route
    // but they will be preserved as query paramaters on the contextual link
    // (which may be needed during the XML request).
    $xml_query = !empty($xml_route_info['options']['query']) ? $xml_route_info['options']['query'] : [];

    // Add a contextual link to view the XML.
    $contextual['juicebox_xml_viewsstyle'] = [
      'route_parameters' => $xml_route_info['route_parameters'] + $xml_query,
    ];
    return $contextual;
  }

  /**
   * Utility to get the item arrays that contain image data from view rows.
   *
   * @param string $source_field
   *   The view field source that will contain a file identifer. The exact part
   *   of the row data to get the file identifer from will depend on the field
   *   type, and this method will resolve that based on the view's field handler
   *   details.
   *
   * @return array
   *   An indexed array, keyed by row id, of file field entities that were
   *   extracted based on row data.
   *
   * @see JuiceboxDiplayStyle::confGetFieldSources()
   */
  protected function getItems($source_field) {
    $view = $this->view;

    // Get the field source options and make sure the passed-source is valid.
    $source_options = $this
      ->confGetFieldSources();
    if (empty($source_options['field_options_images_type'][$source_field])) {
      throw new \Exception($this
        ->t('Empty or invalid field source @source detected for Juicebox view-based gallery.', [
        '@source' => $source_field,
      ]));
    }
    else {
      $source_type = $source_options['field_options_images_type'][$source_field];
    }
    $fids = [];
    $items = [];

    // Pass 1 - get the fids based on the source type.
    foreach ($view->result as $row_index => $row) {
      switch ($source_type) {
        case 'file_id_field':

          // The source is a file ID field so we can fetch the fid from row
          // data directly.
          $target_id = $view->field[$source_field]
            ->getValue($row);
          if (!empty($target_id) && is_numeric($target_id)) {
            $fids[$row_index] = $target_id;
          }
          continue 2;
        case 'file_field':

          // The source is a file field so we fetch the fid through the
          // target_id property if the field item.
          $target_ids = $view->field[$source_field]
            ->getValue($row, 'target_id');

          // The target IDs value comes in a mixed format depending on
          // cardinality. We can only use one ID as each view row can only
          // reference one image (to ensure appropriate matching with the
          // thumb/title/caption data already specified on the row).
          $target_id = is_array($target_ids) ? reset($target_ids) : $target_ids;
          if (!empty($target_id) && is_numeric($target_id)) {
            $fids[$row_index] = $target_id;
          }
      }
    }
    if (empty($items)) {

      // Bulk load all file entities.
      $file_entities = $this->entityTypeManager
        ->getStorage('file')
        ->loadMultiple($fids);

      // Pass 2 - Ensure the file entities are keyed by row.
      foreach ($fids as $row_index => $fid) {
        $items[$row_index] = $file_entities[$fid];
      }
    }
    return $items;
  }

  /**
   * Utility to determine which view fields can be used for image data.
   *
   * This method will extract a list of fields that can be used as "sources"
   * for a Juicebox gallery along with other useful field information.
   *
   * @return array
   *   An associative array containing a breakdown of field data that can be
   *   referenced by other build methods, including:
   *   - field_options_image: An associative array, keyed by field id, of fields
   *     that can be used as Juicebox gallery image sources.
   *   - field_options_image_type: An associative array, keyed by field id, of
   *     field "types" for all fields listed in 'field_options_image' above.
   *   - field_options: An associative array, keyed by field id, of fields that
   *     cannot be used as Juicebox gallery image sources, but may be useful
   *     for other purposes (text and caption sorces, etc.)
   */
  public function confGetFieldSources() {
    $options = [
      'field_options_images' => [],
      'field_options_images_type' => [],
      'field_options' => [],
    ];
    $view = $this->view;
    $field_handlers = $view->display_handler
      ->getHandlers('field');
    $field_labels = $view->display_handler
      ->getFieldLabels();

    // Separate image fields from non-image fields. For image fields we can
    // work with fids and fields of type image or file.
    foreach ($field_handlers as $viewfield => $handler) {
      $is_image = FALSE;
      $id = $handler
        ->getPluginId();
      $name = $field_labels[$viewfield];
      if ($id == 'field') {

        // The field definition is on the handler, it's right bloody there, but
        // it's protected so we can't access it. This means we have to take the
        // long road (via our own injected entity manager) to get the field type
        // info.
        $entity = $this->entityFieldManager
          ->getFieldStorageDefinitions($handler
          ->getEntityType());
        if (isset($handler->field) && array_key_exists($handler->field, $entity)) {
          $field_definition = $entity[$handler->field];
          $field_type = $field_definition
            ->getType();
          if ($field_type == 'image' || $field_type == 'file') {
            $field_cardinality = $field_definition
              ->get('cardinality');
            $options['field_options_images'][$viewfield] = $name . ($field_cardinality == 1 ? '' : '*');
            $options['field_options_images_type'][$viewfield] = 'file_field';
            $is_image = TRUE;
          }
          elseif ($field_type == 'integer' && $handler->field == 'fid') {
            $options['field_options_images'][$viewfield] = $name;
            $options['field_options_images_type'][$viewfield] = 'file_id_field';
            $is_image = TRUE;
          }
        }
      }
      elseif ($id == 'file' && $viewfield == 'fid') {
        $options['field_options_images'][$viewfield] = $name;
        $options['field_options_images_type'][$viewfield] = 'file_id_field';
        $is_image = TRUE;
      }
      if (!$is_image) {
        $options['field_options'][$viewfield] = $name;
      }
    }
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function validate() {
    $errors = parent::validate();
    $pager_options = $this->displayHandler
      ->getOption('pager');
    if (isset($pager_options['type']) && !($pager_options['type'] == 'none' || $pager_options['type'] == 'some')) {

      // @todo: Re-enable this error once issue #2579931 is resolved.
      // $errors[] = $this->stringTranslation->translate('The Juicebox
      // style cannot be used with a pager. Please disable the "Use a pager"
      // option for this display.');
    }
    $style = $this->displayHandler
      ->getOption('style');

    // We want to somewhat "nag" the user if they have not yet configured the
    // Juicebox-specific plugin settings (because things won't work until they
    // do). However, we do NOT want to formally set an error. This is because
    // this validate method can run on pages where the user can't actaully touch
    // the Juicebox-specific plugin settings (such as
    // admin/structure/views/add).
    if (empty($style['options']['image_field']) || empty($style['options']['thumb_field'])) {
      $this
        ->messenger()
        ->addWarning($this->stringTranslation
        ->translate("To ensure a fully functional Juicebox gallery please remember to add at least one field of type Image, File or File ID to your Juicebox view display, and to configure all Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning."), FALSE);
    }
    return $errors;
  }

  /**
   * Utility to extract current set of view args into list of query params.
   *
   * @return array
   *   An array of items that can be used directly as part of the 'query' array
   *   in core URL-building methods. The keys will be numbered numerically as
   *   arg_0, arg_1,... arg_N with the same indexed order of the view args.
   */
  protected function argsToQuery() {
    $query = [];
    foreach ($this->view->args as $key => $arg) {
      $query['arg_' . $key] = $arg;
    }
    return $query;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
JuiceboxDisplayStyle::$entityFieldManager protected property A Drupal entity field manager service.
JuiceboxDisplayStyle::$entityTypeManager protected property A Drupal entity type manager service.
JuiceboxDisplayStyle::$juicebox protected property A Juicebox formatter service.
JuiceboxDisplayStyle::$request protected property A Symfony request object for the current request.
JuiceboxDisplayStyle::$stringTranslation protected property A Drupal string translation service. Overrides StringTranslationTrait::$stringTranslation
JuiceboxDisplayStyle::$usesFields protected property Does the style plugin for itself support to add fields to its output. Overrides StylePluginBase::$usesFields
JuiceboxDisplayStyle::$usesGrouping protected property Does the style plugin support grouping of rows. Overrides StylePluginBase::$usesGrouping
JuiceboxDisplayStyle::$usesOptions protected property Denotes whether the plugin has an additional options form. Overrides StylePluginBase::$usesOptions
JuiceboxDisplayStyle::$usesRowClass protected property Does the style plugin support custom css class for the rows. Overrides StylePluginBase::$usesRowClass
JuiceboxDisplayStyle::$usesRowPlugin protected property Whether or not this style uses a row plugin. Overrides StylePluginBase::$usesRowPlugin
JuiceboxDisplayStyle::argsToQuery protected function Utility to extract current set of view args into list of query params.
JuiceboxDisplayStyle::buildContextualLinks protected function Utility to build contextual links for a viewstyle-based gallery display.
JuiceboxDisplayStyle::buildGallery protected function Build the gallery based on loaded Drupal views data.
JuiceboxDisplayStyle::buildOptionsForm public function Provide a form to edit options for this plugin. Overrides StylePluginBase::buildOptionsForm
JuiceboxDisplayStyle::confGetFieldSources public function Utility to determine which view fields can be used for image data.
JuiceboxDisplayStyle::create public static function Factory to fetch required dependencies from container. Overrides PluginBase::create
JuiceboxDisplayStyle::defineOptions protected function Information about options for all kinds of purposes will be held here. Overrides StylePluginBase::defineOptions
JuiceboxDisplayStyle::getItems protected function Utility to get the item arrays that contain image data from view rows.
JuiceboxDisplayStyle::render public function Render the display in this style. Overrides StylePluginBase::render
JuiceboxDisplayStyle::validate public function Validate that the plugin is correct and can be saved. Overrides StylePluginBase::validate
JuiceboxDisplayStyle::__construct public function Constructs a PluginBase object. Overrides PluginBase::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$definition public property Plugins's definition
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::$renderer protected property Stores the render API renderer. 3
PluginBase::$view public property The top object of a view. 1
PluginBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies 14
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::doFilterByDefinedOptions protected function Do the work to filter out stored options depending on the defined options.
PluginBase::filterByDefinedOptions public function Filter out stored options depending on the defined options. Overrides ViewsPluginInterface::filterByDefinedOptions
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements. Overrides ViewsPluginInterface::getAvailableGlobalTokens
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::getProvider public function Returns the plugin provider. Overrides ViewsPluginInterface::getProvider
PluginBase::getRenderer protected function Returns the render API renderer. 1
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form. Overrides ViewsPluginInterface::globalTokenForm
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced. Overrides ViewsPluginInterface::globalTokenReplace
PluginBase::INCLUDE_ENTITY constant Include entity row languages when listing languages.
PluginBase::INCLUDE_NEGOTIATED constant Include negotiated languages when listing languages.
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::listLanguages protected function Makes an array of languages, optionally including special languages.
PluginBase::pluginTitle public function Return the human readable name of the display. Overrides ViewsPluginInterface::pluginTitle
PluginBase::preRenderAddFieldsetMarkup public static function Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface::preRenderAddFieldsetMarkup
PluginBase::preRenderFlattenData public static function Flattens the structure of form elements. Overrides ViewsPluginInterface::preRenderFlattenData
PluginBase::queryLanguageSubstitutions public static function Returns substitutions for Views queries for languages.
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::submitOptionsForm public function Handle any special handling on the validate form. Overrides ViewsPluginInterface::submitOptionsForm 16
PluginBase::summaryTitle public function Returns the summary of the settings in the display. Overrides ViewsPluginInterface::summaryTitle 6
PluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. Overrides ViewsPluginInterface::themeFunctions 1
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. Overrides ViewsPluginInterface::unpackOptions
PluginBase::usesOptions public function Returns the usesOptions property. Overrides ViewsPluginInterface::usesOptions 8
PluginBase::viewsTokenReplace protected function Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. 1
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT constant Query string to indicate the site default language.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
StylePluginBase::$defaultFieldLabels protected property Should field labels be enabled by default. 1
StylePluginBase::$groupingTheme protected property The theme function used to render the grouping set.
StylePluginBase::$rendered_fields protected property Stores the rendered field values, keyed by the row index and field name.
StylePluginBase::$rowTokens protected property Store all available tokens row rows.
StylePluginBase::buildSort public function Called by the view builder to see if this style handler wants to interfere with the sorts. If so it should build; if it returns any non-TRUE value, normal sorting will NOT be added to the query. 1
StylePluginBase::buildSortPost public function Called by the view builder to let the style build a second set of sorts that will come after any other sorts in the view. 1
StylePluginBase::defaultFieldLabels public function Return TRUE if this style enables field labels by default. 1
StylePluginBase::destroy public function Clears a plugin. Overrides PluginBase::destroy
StylePluginBase::elementPreRenderRow public function #pre_render callback for view row field rendering.
StylePluginBase::evenEmpty public function Should the output of the style plugin be rendered even if it's a empty view. 2
StylePluginBase::getField public function Gets a rendered field.
StylePluginBase::getFieldValue public function Get the raw field value.
StylePluginBase::getRowClass public function Return the token replaced row class for the specified row.
StylePluginBase::init public function Overrides \Drupal\views\Plugin\views\PluginBase::init(). Overrides PluginBase::init
StylePluginBase::preRender public function Allow the style to do stuff before each row is rendered.
StylePluginBase::query public function Add anything to the query that we might need to. Overrides PluginBase::query 1
StylePluginBase::renderFields protected function Renders all of the fields for a given style and store them on the object.
StylePluginBase::renderGrouping public function Group records as needed for rendering.
StylePluginBase::renderGroupingSets public function Render the grouping sets.
StylePluginBase::renderRowGroup protected function Renders a group of rows of the grouped view.
StylePluginBase::tokenizeValue public function Take a value and apply token replacement logic to it.
StylePluginBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides PluginBase::trustedCallbacks
StylePluginBase::usesFields public function Return TRUE if this style also uses fields. 3
StylePluginBase::usesGrouping public function Returns the usesGrouping property. 3
StylePluginBase::usesRowClass public function Returns the usesRowClass property. 3
StylePluginBase::usesRowPlugin public function Returns the usesRowPlugin property. 10
StylePluginBase::usesTokens public function Return TRUE if this style uses tokens.
StylePluginBase::validateOptionsForm public function Validate the options form. Overrides PluginBase::validateOptionsForm
StylePluginBase::wizardForm public function Provide a form in the views wizard if this style is selected.
StylePluginBase::wizardSubmit public function Alter the options of a display before they are added to the view. 1
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.