You are here

class GeoJson in Views GeoJSON 8

Style plugin to render view as GeoJSON code.

Plugin annotation


@ViewsStyle(
    id="geojson",
    title=@Translation("GeoJSON"),
    theme="views_view_geojson",
    description=@Translation("Displays field data in GeoJSON data format."),
    display_types={"data"}
)

Hierarchy

Expanded class hierarchy of GeoJson

File

src/Plugin/views/style/GeoJson.php, line 38

Namespace

Drupal\views_geojson\Plugin\views\style
View source
class GeoJson extends StylePluginBase {

  /**
   * The definition.
   *
   * @var array
   */
  public $definition;

  /**
   * The serializer which serializes the views result.
   *
   * @var \Symfony\Component\Serializer\Serializer
   */
  protected $serializer;

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesFields.
   *
   * @var bool
   */
  protected $usesFields = TRUE;

  /**
   * Overrides Drupal\views\Plugin\views\style\StylePluginBase::$usesGrouping.
   *
   * @var bool
   */
  protected $usesGrouping = FALSE;

  /**
   * Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesRowClass.
   *
   * @var bool
   */
  protected $usesRowClass = FALSE;

  /**
   * Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesRowPlugin.
   *
   * @var bool
   */
  protected $usesRowPlugin = FALSE;

  /**
   * The serializer formats.
   *
   * @var array
   */
  private $formats;

  /**
   * GeoJson constructor.
   *
   * @param array $configuration
   *   The configuration.
   * @param string $plugin_id
   *   The plugin id.
   * @param array $plugin_definition
   *   The plugin definition.
   * @param \Symfony\Component\Serializer\SerializerInterface $serializer
   *   The serializer.
   * @param array $serializer_formats
   *   The serializer formats.
   */
  public function __construct(array $configuration, $plugin_id, array $plugin_definition, SerializerInterface $serializer, array $serializer_formats, ModuleHandlerInterface $module_handler) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->definition = $plugin_definition + $configuration;
    $this->serializer = $serializer;
    $this->formats = [
      'json',
      'html',
    ];
    $this->moduleHandler = $module_handler;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $fields = [];
    $fields_info = [];

    // Get list of fields in this view & flag available geodata fields.
    $handlers = $this->displayHandler
      ->getHandlers('field');
    $field_definition = $this->displayHandler
      ->getOption('fields');

    // Check for any fields, as the view needs them.
    if (empty($handlers)) {
      $form['error_markup'] = [
        '#value' => $this
          ->t('You need to enable at least one field before you can configure your field settings'),
        '#prefix' => '<div class="error form-item description">',
        '#suffix' => '</div>',
      ];
      return;
    }

    // Go through fields, fill $fields and $fields_info arrays.
    foreach ($this->displayHandler
      ->getHandlers('field') as $field_id => $handler) {
      $fields[$field_id] = $handler->definition['title'];
      $fields_info[$field_id]['type'] = $field_definition[$field_id]['type'];
    }

    // Default data source.
    $data_source_options = [
      'latlon' => $this
        ->t('Other: Lat/Lon Point'),
      'geofield' => $this
        ->t('Geofield'),
      'geolocation' => $this
        ->t('Geolocation'),
      'wkt' => $this
        ->t('WKT'),
    ];

    // Data Source options.
    $form['data_source'] = [
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => $this
        ->t('Data Source'),
    ];
    $form['data_source']['value'] = [
      '#type' => 'select',
      '#multiple' => FALSE,
      '#title' => $this
        ->t('Map Data Sources'),
      '#description' => $this
        ->t('Choose which sources of data that the map will provide features for.'),
      '#options' => $data_source_options,
      '#default_value' => $this->options['data_source']['value'],
    ];

    // Other Lat and Lon data sources.
    if (count($fields) > 0) {
      $form['data_source']['latitude'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('Latitude Field'),
        '#description' => $this
          ->t('Choose a field for Latitude.  This should be a field that is a decimal or float value.'),
        '#options' => $fields,
        '#default_value' => $this->options['data_source']['latitude'],
        '#states' => [
          'visible' => [
            ':input[name="style_options[data_source][value]"]' => [
              'value' => 'latlon',
            ],
          ],
        ],
      ];
      $form['data_source']['longitude'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('Longitude Field'),
        '#description' => $this
          ->t('Choose a field for Longitude.  This should be a field that is a decimal or float value.'),
        '#options' => $fields,
        '#default_value' => $this->options['data_source']['longitude'],
        '#states' => [
          'visible' => [
            ':input[name="style_options[data_source][value]"]' => [
              'value' => 'latlon',
            ],
          ],
        ],
      ];

      // Get Geofield-type fields.
      $geofield_fields = [];
      foreach ($fields as $field_id => $field) {

        // @TODO We need to check if the field type is `geofield_default`. But
        // at the moment this information is missing from the array, due to a
        // bug with Geofield 8.x-1.x-dev. When the bug is fixed, we can add a
        // check here again.
        $geofield_fields[$field_id] = $field;
      }

      // Geofield.
      $form['data_source']['geofield'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('Geofield'),
        '#description' => $this
          ->t("Choose a Geofield field. Any formatter will do; we'll access Geofield's underlying WKT format."),
        '#options' => $geofield_fields,
        '#default_value' => $this->options['data_source']['geofield'],
        '#states' => [
          'visible' => [
            ':input[name="style_options[data_source][value]"]' => [
              'value' => 'geofield',
            ],
          ],
        ],
      ];

      // Get Geofield-type fields.
      $geolocation_fields = [];
      foreach ($fields as $field_id => $field) {

        // @todo - need to limit to just geolocation fields.
        $geolocation_fields[$field_id] = $field;
      }

      // Geolocation.
      $form['data_source']['geolocation'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('Geolocation'),
        '#description' => $this
          ->t("Choose a Geolocation field. Any formatter will do; we'll access Geolocation's underlying data storage."),
        '#options' => $geolocation_fields,
        '#default_value' => $this->options['data_source']['geolocation'],
        '#states' => [
          'visible' => [
            ':input[name="style_options[data_source][value]"]' => [
              'value' => 'geolocation',
            ],
          ],
        ],
      ];

      // WKT.
      $form['data_source']['wkt'] = [
        '#type' => 'select',
        '#title' => $this
          ->t('WKT'),
        '#description' => $this
          ->t('Choose a WKT format field.'),
        '#options' => $fields,
        '#default_value' => $this->options['data_source']['wkt'],
        '#states' => [
          'visible' => [
            ':input[name="style_options[data_source][value]"]' => [
              'value' => 'wkt',
            ],
          ],
        ],
      ];
    }
    $form['data_source']['name_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Title Field'),
      '#description' => $this
        ->t('Choose the field to appear as title on tooltips.'),
      '#options' => array_merge([
        '' => '',
      ], $fields),
      '#default_value' => $this->options['data_source']['name_field'],
    ];
    $form['data_source']['description_field'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Description'),
      '#description' => $this
        ->t('Choose the field or rendering method to appear as
          description on tooltips.'),
      '#required' => FALSE,
      '#options' => array_merge([
        '' => '',
      ], $fields),
      '#default_value' => $this->options['data_source']['description_field'],
    ];

    // Attributes and variable styling description.
    $form['attributes'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Attributes and Styling'),
      '#description' => $this
        ->t('Attributes are field data attached to each feature.  This can be used with styling to create Variable styling.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    ];
    $form['jsonp_prefix'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('JSONP prefix'),
      '#default_value' => $this->options['jsonp_prefix'],
      '#description' => $this
        ->t('If used the JSON output will be enclosed with parentheses and prefixed by this label, as in the JSONP format.'),
    ];

    // Make array of attributes.
    $variable_fields = [];

    // Add name and description.
    if (!empty($this->options['data_source']['name_field'])) {
      $variable_fields['name'] = '${name}';
    }
    if (!empty($this->options['data_source']['description_field'])) {
      $variable_fields['description'] = '${description}';
    }

    // Go through fields again to ID variable fields.
    // TODO: is it necessary to call getHandlers twice or can we reuse data from
    // $fields?
    foreach ($this->displayHandler
      ->getHandlers('field') as $field => $handler) {
      if ($field !== $this->options['data_source']['name_field'] && $field !== $this->options['data_source']['description_field']) {
        $variable_fields[$field] = '${' . $field . '}';
      }
    }
    $markup = $this
      ->t('Fields added to this view will be attached to their respective feature, (point, line, polygon,) as attributes.
      These attributes can then be used to add variable styling to your themes. This is accomplished by using the %syntax
      syntax in the values for a style.  The following is a list of formatted variables that are currently available;
      these can be placed right in the style interface.', [
      '%syntax' => '${field_name}',
    ]);
    $form['attributes']['styling'][''] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#attributes' => [
        'class' => [
          'description',
        ],
      ],
      '#markup' => $markup,
    ];
    $form['attributes']['styling'][] = [
      '#theme' => 'item_list',
      '#items' => $variable_fields,
      '#attributes' => [
        'class' => [
          'description',
        ],
      ],
    ];
    $form['attributes']['styling'][''] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#attributes' => [
        'class' => [
          'description',
        ],
      ],
      '#value' => $this
        ->t('Please note that this does not apply to Grouped Displays.'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('serializer'), $container
      ->getParameter('serializer.formats'), $container
      ->get('module_handler'));
  }

  /**
   * {@inheritdoc}
   */
  public function getFormats() {
    return [
      'json',
      'html',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    $features = [
      'type' => 'FeatureCollection',
      'features' => [],
    ];

    // Get the excluded fields array, common for all rows.
    $excluded_fields = $this
      ->getExcludedFields();

    // Render each row.
    foreach ($this->view->result as $i => $row) {
      $this->view->row_index = $i;
      if ($feature = $this
        ->renderRow($row, $excluded_fields)) {
        $features['features'][] = $feature;
      }
    }
    $this->moduleHandler
      ->alter('geojson_view', $features, $this->view);
    unset($this->view->row_index);
    if (!empty($this->view->live_preview)) {

      // Pretty-print the JSON.
      $json = json_encode($features, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRETTY_PRINT);
    }
    else {

      // Render the collection to JSON using Drupal standard renderer.
      $json = Json::encode($features);
    }
    if (!empty($this->options['jsonp_prefix'])) {
      $json = $this->options['jsonp_prefix'] . "({$json})";
    }

    // Everything else returns output.
    return $json;
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['data_source'] = [
      'contains' => [
        'value' => [
          'default' => 'asc',
        ],
        'latitude' => [
          'default' => 0,
        ],
        'longitude' => [
          'default' => 0,
        ],
        'geofield' => [
          'default' => 0,
        ],
        'geolocation' => [
          'default' => 0,
        ],
        'wkt' => [
          'default' => 0,
        ],
        'name_field' => [
          'default' => 0,
        ],
        'description_field' => [
          'default' => 0,
        ],
      ],
    ];
    $options['attributes'] = [
      'default' => NULL,
      'translatable' => FALSE,
    ];
    $options['jsonp_prefix'] = [
      'default' => NULL,
      'translatable' => FALSE,
    ];
    return $options;
  }

  /**
   * Retrieves the list of excluded fields due to style plugin configuration.
   *
   * @return array
   *   List of excluded fields.
   */
  protected function getExcludedFields() {
    $data_source = $this->options['data_source'];
    $excluded_fields = [
      $data_source['name_field'],
      $data_source['description_field'],
    ];
    switch ($data_source['value']) {
      case 'latlon':
        $excluded_fields[] = $data_source['latitude'];
        $excluded_fields[] = $data_source['longitude'];
        break;
      case 'geofield':
        $excluded_fields[] = $data_source['geofield'];
        break;
      case 'geolocation':
        $excluded_fields[] = $data_source['geolocation'];
        break;
      case 'wkt':
        $excluded_fields[] = $data_source['wkt'];
        break;
    }
    return array_combine($excluded_fields, $excluded_fields);
  }

  /**
   * Retrieves the description field value.
   *
   * @param \Drupal\views\ResultRow $row
   *   The result row.
   *
   * @return string
   *   The main field value.
   */
  protected function renderDescriptionField(ResultRow $row) {
    return $this
      ->renderMainField($row, 'description_field');
  }

  /**
   * Retrieves the main fields values.
   *
   * @param \Drupal\views\ResultRow $row
   *   The result row.
   * @param string $field_name
   *   The main field name.
   *
   * @return string
   *   The main field value.
   */
  protected function renderMainField(ResultRow $row, $field_name) {
    if ($this->options['data_source'][$field_name]) {
      if (empty($this->view->field[$this->options['data_source'][$field_name]]->view->row_index)) {
        $this->view->field[$this->options['data_source'][$field_name]]->view->row_index = $row->index;
      }
      return $this->view->field[$this->options['data_source'][$field_name]]
        ->advancedRender($row);
    }
    return '';
  }

  /**
   * Retrieves the name field value.
   *
   * @param \Drupal\views\ResultRow $row
   *   The result row.
   *
   * @return string
   *   The main field value.
   */
  protected function renderNameField(ResultRow $row) {
    return $this
      ->renderMainField($row, 'name_field');
  }

  /**
   * Render views fields to GeoJSON.
   *
   * Takes each field from a row object and renders the field as determined by
   * the field's theme.
   *
   * @param \Drupal\views\ResultRow $row
   *   Row object.
   * @param array $excluded_fields
   *   Array containing field keys to be excluded.
   *
   * @throws Exception
   *
   * @return array
   *   Array containing all the raw and rendered fields
   */
  protected function renderRow(ResultRow $row, array $excluded_fields) {
    $feature = [
      'type' => 'Feature',
    ];
    $data_source = $this->options['data_source'];

    // Pre-render fields to handle those rewritten with tokens.
    foreach ($this->view->field as $field_idx => $field) {
      $field
        ->advancedRender($row);
    }
    switch ($data_source['value']) {
      case 'latlon':
        $latitude = (string) $this->view->field[$data_source['latitude']]
          ->advancedRender($row);
        $longitude = (string) $this->view->field[$data_source['longitude']]
          ->advancedRender($row);
        if (!empty($latitude) && !empty($longitude)) {
          $feature['geometry'] = [
            'type' => 'Point',
            'coordinates' => [
              (double) $longitude,
              (double) $latitude,
            ],
          ];
        }
        break;
      case 'geofield':
        $geofield = $this->view->style_plugin
          ->getFieldValue($row->index, $data_source['geofield']);
        if (!empty($geofield)) {
          $geometry = Drupal::getContainer()
            ->get('geofield.geophp')
            ->load($geofield);
          if (is_object($geometry)) {
            $feature['geometry'] = Json::decode($geometry
              ->out('json'));
          }
        }
        break;
      case 'geolocation':
        $geo_items = $this->view->field[$data_source['geolocation']]
          ->getItems($row);
        if (!empty($geo_items[0]['raw'])) {
          $raw_geo_item = $geo_items[0]['raw'];
          $wkt = "POINT({$raw_geo_item->lng} {$raw_geo_item->lat})";
          $geometry = geoPHP::load($wkt, 'wkt');
          if (is_object($geometry)) {
            $feature['geometry'] = Json::decode($geometry
              ->out('json'));
          }
        }
        break;
      case 'wkt':
        $wkt = (string) $this->view->field[$data_source['wkt']]
          ->advancedRender($row);
        if (!empty($wkt)) {
          $wkt = explode(',', $wkt);
          $geometry = geoPHP::load($wkt, 'wkt');
          if (is_object($geometry)) {
            $feature['geometry'] = Json::decode($geometry
              ->out('json'));
          }
        }
        break;
    }

    // Only add features with geometry data.
    if (empty($feature['geometry'])) {
      return;
    }

    // Add the name and description attributes
    // as chosen through interface.
    $feature['properties']['name'] = $this
      ->renderNameField($row);
    $feature['properties']['description'] = $this
      ->renderDescriptionField($row);

    // Fill in attributes that are not:
    // - Coordinate fields,
    // - Name/description (already processed),
    // - Views "excluded" fields.
    foreach (array_keys($this->view->field) as $id) {
      $field = $this->view->field[$id];
      if (!isset($excluded_fields[$id]) && !$field->options['exclude']) {

        // Allows you to customize the name of the property by setting a label
        // to the field.
        $key = empty($field->options['label']) ? $id : $field->options['label'];
        $value_rendered = $field
          ->advancedRender($row);
        $feature['properties'][$key] = is_numeric($value_rendered) ? (double) $value_rendered : $value_rendered;
      }
    }
    return $feature;
  }

}

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
GeoJson::$definition public property The definition. Overrides PluginBase::$definition
GeoJson::$formats private property The serializer formats.
GeoJson::$moduleHandler protected property The module handler.
GeoJson::$serializer protected property The serializer which serializes the views result.
GeoJson::$usesFields protected property Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesFields. Overrides StylePluginBase::$usesFields
GeoJson::$usesGrouping protected property Overrides Drupal\views\Plugin\views\style\StylePluginBase::$usesGrouping. Overrides StylePluginBase::$usesGrouping
GeoJson::$usesRowClass protected property Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesRowClass. Overrides StylePluginBase::$usesRowClass
GeoJson::$usesRowPlugin protected property Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesRowPlugin. Overrides StylePluginBase::$usesRowPlugin
GeoJson::buildOptionsForm public function Provide a form to edit options for this plugin. Overrides StylePluginBase::buildOptionsForm
GeoJson::create public static function Creates an instance of the plugin. Overrides PluginBase::create
GeoJson::defineOptions protected function Information about options for all kinds of purposes will be held here. Overrides StylePluginBase::defineOptions
GeoJson::getExcludedFields protected function Retrieves the list of excluded fields due to style plugin configuration.
GeoJson::getFormats public function
GeoJson::render public function Render the display in this style. Overrides StylePluginBase::render
GeoJson::renderDescriptionField protected function Retrieves the description field value.
GeoJson::renderMainField protected function Retrieves the main fields values.
GeoJson::renderNameField protected function Retrieves the name field value.
GeoJson::renderRow protected function Render views fields to GeoJSON.
GeoJson::__construct public function GeoJson constructor. 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::$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::$stringTranslation protected property The string translation service. 1
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::$usesOptions protected property Denotes whether the plugin has an additional options form. Overrides PluginBase::$usesOptions
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::validate public function Validate that the plugin is correct and can be saved. Overrides PluginBase::validate
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.