class FieldPluginBase

Same name in this branch
  1. 9 core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
Same name in other branches
  1. 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
  2. 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase
  3. 10 core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
  4. 10 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase
  5. 11.x core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
  6. 11.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase

Base class for views fields.

Hierarchy

Expanded class hierarchy of FieldPluginBase

Related topics

13 files declare their use of FieldPluginBase
ContextualLinks.php in core/modules/contextual/src/Plugin/views/field/ContextualLinks.php
DblogMessage.php in core/modules/dblog/src/Plugin/views/field/DblogMessage.php
DblogOperations.php in core/modules/dblog/src/Plugin/views/field/DblogOperations.php
EntityLink.php in core/modules/comment/src/Plugin/views/field/EntityLink.php
FieldFormButtonTest.php in core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php

... See full list

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 53

Namespace

Drupal\views\Plugin\views\field
View source
abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterface {
    
    /**
     * Indicator of the renderText() method for rendering a single item.
     *
     * (If no render_item() is present).
     */
    const RENDER_TEXT_PHASE_SINGLE_ITEM = 0;
    
    /**
     * Indicator of the renderText() method for rendering the whole element.
     *
     * (if no render_item() method is available).
     */
    const RENDER_TEXT_PHASE_COMPLETELY = 1;
    
    /**
     * Indicator of the renderText() method for rendering the empty text.
     */
    const RENDER_TEXT_PHASE_EMPTY = 2;
    
    /**
     * @var string
     */
    public $field_alias = 'unknown';
    public $aliases = [];
    
    /**
     * The field value prior to any rewriting.
     *
     * @var mixed
     */
    public $original_value = NULL;
    
    /**
     * Stores additional fields which get added to the query.
     *
     * The generated aliases are stored in $aliases.
     *
     * @var array
     */
    public $additional_fields = [];
    
    /**
     * The link generator.
     *
     * @var \Drupal\Core\Utility\LinkGeneratorInterface
     */
    protected $linkGenerator;
    
    /**
     * Stores the render API renderer.
     *
     * @var \Drupal\Core\Render\RendererInterface
     */
    protected $renderer;
    
    /**
     * Keeps track of the last render index.
     *
     * @var int|null
     */
    protected $lastRenderIndex;
    
    /**
     * {@inheritdoc}
     */
    public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
        parent::init($view, $display, $options);
        $this->additional_fields = [];
        if (!empty($this->definition['additional fields'])) {
            $this->additional_fields = $this->definition['additional fields'];
        }
        if (!isset($this->options['exclude'])) {
            $this->options['exclude'] = '';
        }
    }
    
    /**
     * Determine if this field can allow advanced rendering.
     *
     * Fields can set this to FALSE if they do not wish to allow
     * token based rewriting or link-making.
     */
    protected function allowAdvancedRender() {
        return TRUE;
    }
    
    /**
     * Called to add the field to a query.
     */
    public function query() {
        $this->ensureMyTable();
        // Add the field.
        $params = $this->options['group_type'] != 'group' ? [
            'function' => $this->options['group_type'],
        ] : [];
        $this->field_alias = $this->query
            ->addField($this->tableAlias, $this->realField, NULL, $params);
        $this->addAdditionalFields();
    }
    
    /**
     * Add 'additional' fields to the query.
     *
     * @param $fields
     *   An array of fields. The key is an identifier used to later find the
     *   field alias used. The value is either a string in which case it's
     *   assumed to be a field on this handler's table; or it's an array in the
     *   form of
     *   @code array('table' => $tablename, 'field' => $fieldname) @endcode
     */
    protected function addAdditionalFields($fields = NULL) {
        if (!isset($fields)) {
            // notice check
            if (empty($this->additional_fields)) {
                return;
            }
            $fields = $this->additional_fields;
        }
        $group_params = [];
        if ($this->options['group_type'] != 'group') {
            $group_params = [
                'function' => $this->options['group_type'],
            ];
        }
        if (!empty($fields) && is_array($fields)) {
            foreach ($fields as $identifier => $info) {
                if (is_array($info)) {
                    if (isset($info['table'])) {
                        $table_alias = $this->query
                            ->ensureTable($info['table'], $this->relationship);
                    }
                    else {
                        $table_alias = $this->tableAlias;
                    }
                    if (empty($table_alias)) {
                        trigger_error(sprintf("Handler %s tried to add additional_field %s but %s could not be added!", $this->definition['id'], $identifier, $info['table']), E_USER_WARNING);
                        $this->aliases[$identifier] = 'broken';
                        continue;
                    }
                    $params = [];
                    if (!empty($info['params'])) {
                        $params = $info['params'];
                    }
                    $params += $group_params;
                    $this->aliases[$identifier] = $this->query
                        ->addField($table_alias, $info['field'], NULL, $params);
                }
                else {
                    $this->aliases[$info] = $this->query
                        ->addField($this->tableAlias, $info, NULL, $group_params);
                }
            }
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public function clickSort($order) {
        if (isset($this->field_alias)) {
            // Since fields should always have themselves already added, just
            // add a sort on the field.
            $params = $this->options['group_type'] != 'group' ? [
                'function' => $this->options['group_type'],
            ] : [];
            $this->query
                ->addOrderBy(NULL, NULL, $order, $this->field_alias, $params);
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public function clickSortable() {
        return $this->definition['click sortable'] ?? TRUE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function label() {
        if (!isset($this->options['label'])) {
            return '';
        }
        return $this->options['label'];
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementType($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
        if ($none_supported) {
            if ($this->options['element_type'] === '0') {
                return '';
            }
        }
        if ($this->options['element_type']) {
            return $this->options['element_type'];
        }
        if ($default_empty) {
            return '';
        }
        if ($inline) {
            return 'span';
        }
        if (isset($this->definition['element type'])) {
            return $this->definition['element type'];
        }
        return 'span';
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementLabelType($none_supported = FALSE, $default_empty = FALSE) {
        if ($none_supported) {
            if ($this->options['element_label_type'] === '0') {
                return '';
            }
        }
        if ($this->options['element_label_type']) {
            return $this->options['element_label_type'];
        }
        if ($default_empty) {
            return '';
        }
        return 'span';
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementWrapperType($none_supported = FALSE, $default_empty = FALSE) {
        if ($none_supported) {
            if ($this->options['element_wrapper_type'] === '0') {
                return 0;
            }
        }
        if ($this->options['element_wrapper_type']) {
            return $this->options['element_wrapper_type'];
        }
        if ($default_empty) {
            return '';
        }
        return 'div';
    }
    
    /**
     * {@inheritdoc}
     */
    public function getElements() {
        static $elements = NULL;
        if (!isset($elements)) {
            // @todo Add possible html5 elements.
            $elements = [
                '' => $this->t('- Use default -'),
                '0' => $this->t('- None -'),
            ];
            $elements += \Drupal::config('views.settings')->get('field_rewrite_elements');
        }
        return $elements;
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementClasses($row_index = NULL) {
        $classes = $this->tokenizeValue($this->options['element_class'], $row_index);
        $classes = explode(' ', $classes);
        foreach ($classes as &$class) {
            $class = Html::cleanCssIdentifier($class);
        }
        return implode(' ', $classes);
    }
    
    /**
     * {@inheritdoc}
     */
    public function tokenizeValue($value, $row_index = NULL) {
        if (strpos($value, '{{') !== FALSE) {
            $fake_item = [
                'alter_text' => TRUE,
                'text' => $value,
            ];
            // Use isset() because empty() will trigger on 0 and 0 is
            // the first row.
            if (isset($row_index) && isset($this->view->style_plugin->render_tokens[$row_index])) {
                $tokens = $this->view->style_plugin->render_tokens[$row_index];
            }
            else {
                // Get tokens from the last field.
                $last_field = end($this->view->field);
                if (isset($last_field->last_tokens)) {
                    $tokens = $last_field->last_tokens;
                }
                else {
                    $tokens = $last_field->getRenderTokens($fake_item);
                }
            }
            $value = strip_tags($this->renderAltered($fake_item, $tokens));
            if (!empty($this->options['alter']['trim_whitespace'])) {
                $value = trim($value);
            }
        }
        return $value;
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementLabelClasses($row_index = NULL) {
        $classes = $this->tokenizeValue($this->options['element_label_class'], $row_index);
        $classes = explode(' ', $classes);
        foreach ($classes as &$class) {
            $class = Html::cleanCssIdentifier($class);
        }
        return implode(' ', $classes);
    }
    
    /**
     * {@inheritdoc}
     */
    public function elementWrapperClasses($row_index = NULL) {
        $classes = $this->tokenizeValue($this->options['element_wrapper_class'], $row_index);
        $classes = explode(' ', $classes);
        foreach ($classes as &$class) {
            $class = Html::cleanCssIdentifier($class);
        }
        return implode(' ', $classes);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getEntity(ResultRow $values) {
        $relationship_id = $this->options['relationship'];
        if ($relationship_id == 'none') {
            return $values->_entity;
        }
        elseif (isset($values->_relationship_entities[$relationship_id])) {
            return $values->_relationship_entities[$relationship_id];
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public function getValue(ResultRow $values, $field = NULL) {
        $alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
        if (isset($values->{$alias})) {
            return $values->{$alias};
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public function useStringGroupBy() {
        return TRUE;
    }
    protected function defineOptions() {
        $options = parent::defineOptions();
        $options['label'] = [
            'default' => '',
        ];
        // Some styles (for example table) should have labels enabled by default.
        $style = $this->view
            ->getStyle();
        if (isset($style) && $style->defaultFieldLabels()) {
            $options['label']['default'] = $this->definition['title'];
        }
        $options['exclude'] = [
            'default' => FALSE,
        ];
        $options['alter'] = [
            'contains' => [
                'alter_text' => [
                    'default' => FALSE,
                ],
                'text' => [
                    'default' => '',
                ],
                'make_link' => [
                    'default' => FALSE,
                ],
                'path' => [
                    'default' => '',
                ],
                'absolute' => [
                    'default' => FALSE,
                ],
                'external' => [
                    'default' => FALSE,
                ],
                'replace_spaces' => [
                    'default' => FALSE,
                ],
                'path_case' => [
                    'default' => 'none',
                ],
                'trim_whitespace' => [
                    'default' => FALSE,
                ],
                'alt' => [
                    'default' => '',
                ],
                'rel' => [
                    'default' => '',
                ],
                'link_class' => [
                    'default' => '',
                ],
                'prefix' => [
                    'default' => '',
                ],
                'suffix' => [
                    'default' => '',
                ],
                'target' => [
                    'default' => '',
                ],
                'nl2br' => [
                    'default' => FALSE,
                ],
                'max_length' => [
                    'default' => 0,
                ],
                'word_boundary' => [
                    'default' => TRUE,
                ],
                'ellipsis' => [
                    'default' => TRUE,
                ],
                'more_link' => [
                    'default' => FALSE,
                ],
                'more_link_text' => [
                    'default' => '',
                ],
                'more_link_path' => [
                    'default' => '',
                ],
                'strip_tags' => [
                    'default' => FALSE,
                ],
                'trim' => [
                    'default' => FALSE,
                ],
                'preserve_tags' => [
                    'default' => '',
                ],
                'html' => [
                    'default' => FALSE,
                ],
            ],
        ];
        $options['element_type'] = [
            'default' => '',
        ];
        $options['element_class'] = [
            'default' => '',
        ];
        $options['element_label_type'] = [
            'default' => '',
        ];
        $options['element_label_class'] = [
            'default' => '',
        ];
        $options['element_label_colon'] = [
            'default' => TRUE,
        ];
        $options['element_wrapper_type'] = [
            'default' => '',
        ];
        $options['element_wrapper_class'] = [
            'default' => '',
        ];
        $options['element_default_classes'] = [
            'default' => TRUE,
        ];
        $options['empty'] = [
            'default' => '',
        ];
        $options['hide_empty'] = [
            'default' => FALSE,
        ];
        $options['empty_zero'] = [
            'default' => FALSE,
        ];
        $options['hide_alter_empty'] = [
            'default' => TRUE,
        ];
        return $options;
    }
    
    /**
     * Performs some cleanup tasks on the options array before saving it.
     */
    public function submitOptionsForm(&$form, FormStateInterface $form_state) {
        $options =& $form_state->getValue('options');
        $types = [
            'element_type',
            'element_label_type',
            'element_wrapper_type',
        ];
        $classes = array_combine([
            'element_class',
            'element_label_class',
            'element_wrapper_class',
        ], $types);
        foreach ($types as $type) {
            if (!$options[$type . '_enable']) {
                $options[$type] = '';
            }
        }
        foreach ($classes as $class => $type) {
            if (!$options[$class . '_enable'] || !$options[$type . '_enable']) {
                $options[$class] = '';
            }
        }
        if (empty($options['custom_label'])) {
            $options['label'] = '';
            $options['element_label_colon'] = FALSE;
        }
    }
    
    /**
     * Default option form that provides label widget that all fields should have.
     */
    public function buildOptionsForm(&$form, FormStateInterface $form_state) {
        parent::buildOptionsForm($form, $form_state);
        $label = $this->label();
        $form['custom_label'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Create a label'),
            '#default_value' => $label !== '',
            '#weight' => -103,
        ];
        $form['label'] = [
            '#type' => 'textfield',
            '#title' => $this->t('Label'),
            '#default_value' => $label,
            '#states' => [
                'visible' => [
                    ':input[name="options[custom_label]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#weight' => -102,
        ];
        $form['element_label_colon'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Place a colon after the label'),
            '#default_value' => $this->options['element_label_colon'],
            '#states' => [
                'visible' => [
                    ':input[name="options[custom_label]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#weight' => -101,
        ];
        $form['exclude'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Exclude from display'),
            '#default_value' => $this->options['exclude'],
            '#description' => $this->t('Enable to load this field as hidden. Often used to group fields, or to use as token in another field.'),
            '#weight' => -100,
        ];
        $form['style_settings'] = [
            '#type' => 'details',
            '#title' => $this->t('Style settings'),
            '#weight' => 99,
        ];
        $form['element_type_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Customize field HTML'),
            '#default_value' => !empty($this->options['element_type']) || (string) $this->options['element_type'] == '0' || !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_type'] = [
            '#title' => $this->t('HTML element'),
            '#options' => $this->getElements(),
            '#type' => 'select',
            '#default_value' => $this->options['element_type'],
            '#description' => $this->t('Choose the HTML element to wrap around this field, e.g. H1, H2, etc.'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_class_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Add HTML class'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#default_value' => !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_class'] = [
            '#title' => $this->t('CSS class'),
            '#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
            '#type' => 'textfield',
            '#default_value' => $this->options['element_class'],
            '#states' => [
                'visible' => [
                    ':input[name="options[element_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                    ':input[name="options[element_class_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_label_type_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Customize label HTML'),
            '#default_value' => !empty($this->options['element_label_type']) || (string) $this->options['element_label_type'] == '0' || !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_label_type'] = [
            '#title' => $this->t('Label HTML element'),
            '#options' => $this->getElements(FALSE),
            '#type' => 'select',
            '#default_value' => $this->options['element_label_type'],
            '#description' => $this->t('Choose the HTML element to wrap around this label, e.g. H1, H2, etc.'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_label_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_label_class_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Add HTML class'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_label_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_label_class'] = [
            '#title' => $this->t('CSS class'),
            '#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
            '#type' => 'textfield',
            '#default_value' => $this->options['element_label_class'],
            '#states' => [
                'visible' => [
                    ':input[name="options[element_label_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                    ':input[name="options[element_label_class_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_wrapper_type_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Customize field and label wrapper HTML'),
            '#default_value' => !empty($this->options['element_wrapper_type']) || (string) $this->options['element_wrapper_type'] == '0' || !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_wrapper_type'] = [
            '#title' => $this->t('Wrapper HTML element'),
            '#options' => $this->getElements(FALSE),
            '#type' => 'select',
            '#default_value' => $this->options['element_wrapper_type'],
            '#description' => $this->t('Choose the HTML element to wrap around this field and label, e.g. H1, H2, etc. This may not be used if the field and label are not rendered together, such as with a table.'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_wrapper_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_wrapper_class_enable'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Add HTML class'),
            '#states' => [
                'visible' => [
                    ':input[name="options[element_wrapper_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#default_value' => !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0',
            '#fieldset' => 'style_settings',
        ];
        $form['element_wrapper_class'] = [
            '#title' => $this->t('CSS class'),
            '#description' => $this->t('You may use token substitutions from the rewriting section in this class.'),
            '#type' => 'textfield',
            '#default_value' => $this->options['element_wrapper_class'],
            '#states' => [
                'visible' => [
                    ':input[name="options[element_wrapper_class_enable]"]' => [
                        'checked' => TRUE,
                    ],
                    ':input[name="options[element_wrapper_type_enable]"]' => [
                        'checked' => TRUE,
                    ],
                ],
            ],
            '#fieldset' => 'style_settings',
        ];
        $form['element_default_classes'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Add default classes'),
            '#default_value' => $this->options['element_default_classes'],
            '#description' => $this->t('Use default Views classes to identify the field, field label and field content.'),
            '#fieldset' => 'style_settings',
        ];
        $form['alter'] = [
            '#title' => $this->t('Rewrite results'),
            '#type' => 'details',
            '#weight' => 100,
        ];
        if ($this->allowAdvancedRender()) {
            $form['alter']['#tree'] = TRUE;
            $form['alter']['alter_text'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Override the output of this field with custom text'),
                '#default_value' => $this->options['alter']['alter_text'],
            ];
            $form['alter']['text'] = [
                '#title' => $this->t('Text'),
                '#type' => 'textarea',
                '#default_value' => $this->options['alter']['text'],
                // The tag list will be escaped.
'#description' => $this->t('The text to display for this field. You may enter data from this view as per the "Replacement patterns" below. You may include <a href="@twig_docs">Twig</a> or the following allowed HTML tags: <code>@tags</code>', [
                    '@twig_docs' => 'https://twig.symfony.com/doc/' . Environment::MAJOR_VERSION . '.x',
                    '@tags' => '<' . implode('> <', Xss::getAdminTagList()) . '>',
                ]),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][alter_text]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['make_link'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Output this field as a custom link'),
                '#default_value' => $this->options['alter']['make_link'],
            ];
            $form['alter']['path'] = [
                '#title' => $this->t('Link path'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['path'],
                '#description' => $this->t('The Drupal path or absolute URL for this link. You may enter data from this view as per the "Replacement patterns" below.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
                '#maxlength' => 255,
            ];
            $form['alter']['absolute'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Use absolute path'),
                '#default_value' => $this->options['alter']['absolute'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['replace_spaces'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Replace spaces with dashes'),
                '#default_value' => $this->options['alter']['replace_spaces'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['external'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('External server URL'),
                '#default_value' => $this->options['alter']['external'],
                '#description' => $this->t("Links to an external server using a full URL: e.g. 'http://www.example.com' or 'www.example.com'."),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['path_case'] = [
                '#type' => 'select',
                '#title' => $this->t('Transform the case'),
                '#description' => $this->t('When printing URL paths, how to transform the case of the filter value.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
                '#options' => [
                    'none' => $this->t('No transform'),
                    'upper' => $this->t('Upper case'),
                    'lower' => $this->t('Lower case'),
                    'ucfirst' => $this->t('Capitalize first letter'),
                    'ucwords' => $this->t('Capitalize each word'),
                ],
                '#default_value' => $this->options['alter']['path_case'],
            ];
            $form['alter']['link_class'] = [
                '#title' => $this->t('Link class'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['link_class'],
                '#description' => $this->t('The CSS class to apply to the link.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['alt'] = [
                '#title' => $this->t('Title text'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['alt'],
                '#description' => $this->t('Text to place as "title" text which most browsers display as a tooltip when hovering over the link.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['rel'] = [
                '#title' => $this->t('Rel Text'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['rel'],
                '#description' => $this->t('Include Rel attribute for use in lightbox2 or other javascript utility.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['prefix'] = [
                '#title' => $this->t('Prefix text'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['prefix'],
                '#description' => $this->t('Any text to display before this link. You may include HTML.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['suffix'] = [
                '#title' => $this->t('Suffix text'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['suffix'],
                '#description' => $this->t('Any text to display after this link. You may include HTML.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['target'] = [
                '#title' => $this->t('Target'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['target'],
                '#description' => $this->t("Target of the link, such as _blank, _parent or an iframe's name. This field is rarely used."),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][make_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            // Get a list of the available fields and arguments for token replacement.
            // Setup the tokens for fields.
            $previous = $this->getPreviousFieldLabels();
            $optgroup_arguments = (string) $this->t('Arguments');
            $optgroup_fields = (string) $this->t('Fields');
            foreach ($previous as $id => $label) {
                $options[$optgroup_fields]["{{ {$id} }}"] = substr(strrchr($label, ":"), 2);
            }
            // Add the field to the list of options.
            $options[$optgroup_fields]["{{ {$this->options['id']} }}"] = substr(strrchr($this->adminLabel(), ":"), 2);
            foreach ($this->view->display_handler
                ->getHandlers('argument') as $arg => $handler) {
                $options[$optgroup_arguments]["{{ arguments.{$arg} }}"] = $this->t('@argument title', [
                    '@argument' => $handler->adminLabel(),
                ]);
                $options[$optgroup_arguments]["{{ raw_arguments.{$arg} }}"] = $this->t('@argument input', [
                    '@argument' => $handler->adminLabel(),
                ]);
            }
            $this->documentSelfTokens($options[$optgroup_fields]);
            // Default text.
            $output = [];
            $output[] = [
                '#markup' => '<p>' . $this->t('You must add some additional fields to this display before using this field. These fields may be marked as <em>Exclude from display</em> if you prefer. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.') . '</p>',
            ];
            // We have some options, so make a list.
            if (!empty($options)) {
                $output[] = [
                    '#markup' => '<p>' . $this->t("The following replacement tokens are available for this field. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.") . '</p>',
                ];
                foreach (array_keys($options) as $type) {
                    if (!empty($options[$type])) {
                        $items = [];
                        foreach ($options[$type] as $key => $value) {
                            $items[] = $key . ' == ' . $value;
                        }
                        $item_list = [
                            '#theme' => 'item_list',
                            '#items' => $items,
                        ];
                        $output[] = $item_list;
                    }
                }
            }
            // This construct uses 'hidden' and not markup because process doesn't
            // run. It also has an extra div because the dependency wants to hide
            // the parent in situations like this, so we need a second div to
            // make this work.
            $form['alter']['help'] = [
                '#type' => 'details',
                '#title' => $this->t('Replacement patterns'),
                '#value' => $output,
                '#states' => [
                    'visible' => [
                        [
                            ':input[name="options[alter][make_link]"]' => [
                                'checked' => TRUE,
                            ],
                        ],
                        [
                            ':input[name="options[alter][alter_text]"]' => [
                                'checked' => TRUE,
                            ],
                        ],
                        [
                            ':input[name="options[alter][more_link]"]' => [
                                'checked' => TRUE,
                            ],
                        ],
                    ],
                ],
            ];
            $form['alter']['trim'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Trim this field to a maximum number of characters'),
                '#default_value' => $this->options['alter']['trim'],
            ];
            $form['alter']['max_length'] = [
                '#title' => $this->t('Maximum number of characters'),
                '#type' => 'textfield',
                '#default_value' => $this->options['alter']['max_length'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['word_boundary'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Trim only on a word boundary'),
                '#description' => $this->t('If checked, this field be trimmed only on a word boundary. This is guaranteed to be the maximum characters stated or less. If there are no word boundaries this could trim a field to nothing.'),
                '#default_value' => $this->options['alter']['word_boundary'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['ellipsis'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Add "…" at the end of trimmed text'),
                '#default_value' => $this->options['alter']['ellipsis'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['more_link'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Add a read-more link if output is trimmed'),
                '#default_value' => $this->options['alter']['more_link'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['more_link_text'] = [
                '#type' => 'textfield',
                '#title' => $this->t('More link label'),
                '#default_value' => $this->options['alter']['more_link_text'],
                '#description' => $this->t('You may use the "Replacement patterns" above.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                        ':input[name="options[alter][more_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['more_link_path'] = [
                '#type' => 'textfield',
                '#title' => $this->t('More link path'),
                '#default_value' => $this->options['alter']['more_link_path'],
                '#description' => $this->t('This can be an internal Drupal path such as node/add or an external URL such as "https://www.drupal.org". You may use the "Replacement patterns" above.'),
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                        ':input[name="options[alter][more_link]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['html'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Field can contain HTML'),
                '#description' => $this->t('An HTML corrector will be run to ensure HTML tags are properly closed after trimming.'),
                '#default_value' => $this->options['alter']['html'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][trim]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['strip_tags'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Strip HTML tags'),
                '#default_value' => $this->options['alter']['strip_tags'],
            ];
            $form['alter']['preserve_tags'] = [
                '#type' => 'textfield',
                '#title' => $this->t('Preserve certain tags'),
                '#description' => $this->t('List the tags that need to be preserved during the stripping process. example &quot;&lt;p&gt; &lt;br&gt;&quot; which will preserve all p and br elements'),
                '#default_value' => $this->options['alter']['preserve_tags'],
                '#states' => [
                    'visible' => [
                        ':input[name="options[alter][strip_tags]"]' => [
                            'checked' => TRUE,
                        ],
                    ],
                ],
            ];
            $form['alter']['trim_whitespace'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Remove whitespace'),
                '#default_value' => $this->options['alter']['trim_whitespace'],
            ];
            $form['alter']['nl2br'] = [
                '#type' => 'checkbox',
                '#title' => $this->t('Convert newlines to HTML &lt;br&gt; tags'),
                '#default_value' => $this->options['alter']['nl2br'],
            ];
        }
        $form['empty_field_behavior'] = [
            '#type' => 'details',
            '#title' => $this->t('No results behavior'),
            '#weight' => 100,
        ];
        $form['empty'] = [
            '#type' => 'textarea',
            '#title' => $this->t('No results text'),
            '#default_value' => $this->options['empty'],
            '#description' => $this->t('Provide text to display if this field contains an empty result. You may include HTML. You may enter data from this view as per the "Replacement patterns" in the "Rewrite Results" section above.'),
            '#fieldset' => 'empty_field_behavior',
        ];
        $form['empty_zero'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Count the number 0 as empty'),
            '#default_value' => $this->options['empty_zero'],
            '#description' => $this->t('Enable to display the "no results text" if the field contains the number 0.'),
            '#fieldset' => 'empty_field_behavior',
        ];
        $form['hide_empty'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Hide if empty'),
            '#default_value' => $this->options['hide_empty'],
            '#description' => $this->t('Enable to hide this field if it is empty. Note that the field label or rewritten output may still be displayed. To hide labels, check the style or row style settings for empty fields. To hide rewritten content, check the "Hide rewriting if empty" checkbox.'),
            '#fieldset' => 'empty_field_behavior',
        ];
        $form['hide_alter_empty'] = [
            '#type' => 'checkbox',
            '#title' => $this->t('Hide rewriting if empty'),
            '#default_value' => $this->options['hide_alter_empty'],
            '#description' => $this->t('Do not display rewritten content if this field is empty.'),
            '#fieldset' => 'empty_field_behavior',
        ];
    }
    
    /**
     * Returns all field labels of fields before this field.
     *
     * @return array
     *   An array of field labels keyed by their field IDs.
     */
    protected function getPreviousFieldLabels() {
        $all_fields = $this->view->display_handler
            ->getFieldLabels();
        $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
        return $field_options;
    }
    
    /**
     * Provide extra data to the administration form.
     */
    public function adminSummary() {
        return $this->label();
    }
    
    /**
     * {@inheritdoc}
     */
    public function preRender(&$values) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function render(ResultRow $values) {
        $value = $this->getValue($values);
        return $this->sanitizeValue($value);
    }
    
    /**
     * {@inheritdoc}
     */
    public function postRender(ResultRow $row, $output) {
        // Make sure the last rendered value is available also when this is
        // retrieved from cache.
        $this->last_render = $output;
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function advancedRender(ResultRow $values) {
        // Clean up values from previous render calls.
        if ($this->lastRenderIndex != $values->index) {
            $this->last_render_text = '';
        }
        if ($this->allowAdvancedRender() && $this instanceof MultiItemsFieldHandlerInterface) {
            $raw_items = $this->getItems($values);
            // If there are no items, set the original value to NULL.
            if (empty($raw_items)) {
                $this->original_value = NULL;
            }
        }
        else {
            $value = $this->render($values);
            if (is_array($value)) {
                $value = $this->getRenderer()
                    ->render($value);
            }
            $this->last_render = $value;
            $this->original_value = $value;
        }
        if ($this->allowAdvancedRender()) {
            if ($this instanceof MultiItemsFieldHandlerInterface) {
                $items = [];
                foreach ($raw_items as $count => $item) {
                    $value = $this->render_item($count, $item);
                    if (is_array($value)) {
                        $value = (string) $this->getRenderer()
                            ->render($value);
                    }
                    $this->last_render = $value;
                    $this->original_value = $this->last_render;
                    $alter = $item + $this->options['alter'];
                    $alter['phase'] = static::RENDER_TEXT_PHASE_SINGLE_ITEM;
                    $items[] = $this->renderText($alter);
                }
                $value = $this->renderItems($items);
            }
            else {
                $alter = [
                    'phase' => static::RENDER_TEXT_PHASE_COMPLETELY,
                ] + $this->options['alter'];
                $value = $this->renderText($alter);
            }
            if (is_array($value)) {
                $value = $this->getRenderer()
                    ->render($value);
            }
            // This happens here so that renderAsLink can get the unaltered value of
            // this field as a token rather than the altered value.
            $this->last_render = $value;
        }
        // String cast is necessary to test emptiness of MarkupInterface
        // objects.
        if (empty((string) $this->last_render)) {
            if ($this->isValueEmpty($this->last_render, $this->options['empty_zero'], FALSE)) {
                $alter = $this->options['alter'];
                $alter['alter_text'] = 1;
                $alter['text'] = $this->options['empty'];
                $alter['phase'] = static::RENDER_TEXT_PHASE_EMPTY;
                $this->last_render = $this->renderText($alter);
            }
        }
        // If we rendered something, update the last render index.
        if ((string) $this->last_render !== '') {
            $this->lastRenderIndex = $values->index;
        }
        return $this->last_render;
    }
    
    /**
     * {@inheritdoc}
     */
    public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE) {
        // Convert MarkupInterface to a string for checking.
        if ($value instanceof MarkupInterface) {
            $value = (string) $value;
        }
        if (!isset($value)) {
            $empty = TRUE;
        }
        else {
            $empty = $empty_zero || $value !== 0 && $value !== '0';
        }
        if ($no_skip_empty) {
            $empty = empty($value) && $empty;
        }
        return $empty;
    }
    
    /**
     * {@inheritdoc}
     */
    public function renderText($alter) {
        // We need to preserve the safeness of the value regardless of the
        // alterations made by this method. Any alterations or replacements made
        // within this method need to ensure that at the minimum the result is
        // XSS admin filtered. See self::renderAltered() as an example that does.
        $value_is_safe = $this->last_render instanceof MarkupInterface;
        // Cast to a string so that empty checks and string functions work as
        // expected.
        $value = (string) $this->last_render;
        if (!empty($alter['alter_text']) && $alter['text'] !== '') {
            $tokens = $this->getRenderTokens($alter);
            $value = $this->renderAltered($alter, $tokens);
            // $alter['text'] is entered through the views admin UI and will be safe
            // because the output of $this->renderAltered() is run through
            // Xss::filterAdmin().
            // @see \Drupal\views\Plugin\views\PluginBase::viewsTokenReplace()
            // @see \Drupal\Component\Utility\Xss::filterAdmin()
            $value_is_safe = TRUE;
        }
        if (!empty($this->options['alter']['trim_whitespace'])) {
            $value = trim($value);
        }
        // Check if there should be no further rewrite for empty values.
        $no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->isValueEmpty($this->original_value, $this->options['empty_zero']);
        // Check whether the value is empty and return nothing, so the field isn't rendered.
        // First check whether the field should be hidden if the value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = FALSE).
        // For numeric values you can specify whether "0"/0 should be empty.
        if (($this->options['hide_empty'] && empty($value) || $alter['phase'] != static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) && $this->isValueEmpty($value, $this->options['empty_zero'], FALSE)) {
            return '';
        }
        // Only in empty phase.
        if ($alter['phase'] == static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) {
            // If we got here then $alter contains the value of "No results text"
            // and so there is nothing left to do.
            return ViewsRenderPipelineMarkup::create($value);
        }
        if (!empty($alter['strip_tags'])) {
            $value = strip_tags($value, $alter['preserve_tags']);
        }
        $more_link = '';
        if (!empty($alter['trim']) && !empty($alter['max_length'])) {
            $length = strlen($value);
            $value = $this->renderTrimText($alter, $value);
            if ($this->options['alter']['more_link'] && strlen($value) < $length) {
                $tokens = $this->getRenderTokens($alter);
                $more_link_text = $this->options['alter']['more_link_text'] ? $this->options['alter']['more_link_text'] : $this->t('more');
                $more_link_text = strtr(Xss::filterAdmin($more_link_text), $tokens);
                $more_link_path = $this->options['alter']['more_link_path'];
                $more_link_path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($more_link_path, $tokens)));
                // Make sure that paths which were run through URL generation work as
                // well.
                $base_path = base_path();
                // Checks whether the path starts with the base_path.
                if (strpos($more_link_path, $base_path) === 0) {
                    $more_link_path = mb_substr($more_link_path, mb_strlen($base_path));
                }
                // @todo Views should expect and store a leading /. See
                //   https://www.drupal.org/node/2423913.
                $options = [
                    'attributes' => [
                        'class' => [
                            'views-more-link',
                        ],
                    ],
                ];
                if (UrlHelper::isExternal($more_link_path)) {
                    $more_link_url = CoreUrl::fromUri($more_link_path, $options);
                }
                else {
                    $more_link_url = CoreUrl::fromUserInput('/' . $more_link_path, $options);
                }
                $more_link = ' ' . $this->linkGenerator()
                    ->generate($more_link_text, $more_link_url);
            }
        }
        if (!empty($alter['nl2br'])) {
            $value = nl2br($value);
        }
        if ($value_is_safe) {
            $value = ViewsRenderPipelineMarkup::create($value);
        }
        $this->last_render_text = $value;
        if (!empty($alter['make_link']) && (!empty($alter['path']) || !empty($alter['url']))) {
            if (!isset($tokens)) {
                $tokens = $this->getRenderTokens($alter);
            }
            $value = $this->renderAsLink($alter, $value, $tokens);
        }
        // Preserve whether or not the string is safe. Since $more_link comes from
        // \Drupal::l(), it is safe to append. Check if the value is an instance of
        // \Drupal\Component\Render\MarkupInterface here because renderAsLink()
        // can return both safe and unsafe values.
        if ($value instanceof MarkupInterface) {
            return ViewsRenderPipelineMarkup::create($value . $more_link);
        }
        else {
            // If the string is not already marked safe, it is still OK to return it
            // because it will be sanitized by Twig.
            return $value . $more_link;
        }
    }
    
    /**
     * Render this field as user-defined altered text.
     */
    protected function renderAltered($alter, $tokens) {
        return $this->viewsTokenReplace($alter['text'], $tokens);
    }
    
    /**
     * Trims the field down to the specified length.
     *
     * @param array $alter
     *   The alter array of options to use.
     *     - max_length: Maximum length of the string, the rest gets truncated.
     *     - word_boundary: Trim only on a word boundary.
     *     - ellipsis: Show an ellipsis (…) at the end of the trimmed string.
     *     - html: Make sure that the html is correct.
     * @param string $value
     *   The string which should be trimmed.
     *
     * @return string
     *   The rendered trimmed string.
     */
    protected function renderTrimText($alter, $value) {
        if (!empty($alter['strip_tags'])) {
            // NOTE: It's possible that some external fields might override the
            // element type.
            $this->definition['element type'] = 'span';
        }
        return static::trimText($alter, $value);
    }
    
    /**
     * Render this field as a link, with the info from a fieldset set by the user.
     */
    protected function renderAsLink($alter, $text, $tokens) {
        $options = [
            'absolute' => !empty($alter['absolute']) ? TRUE : FALSE,
            'alias' => FALSE,
            'entity' => NULL,
            'entity_type' => NULL,
            'fragment' => NULL,
            'language' => NULL,
            'query' => [],
        ];
        $alter += [
            'path' => NULL,
        ];
        $path = $alter['path'];
        // strip_tags() and viewsTokenReplace remove <front>, so check whether it's
        // different to front.
        if ($path != '<front>') {
            // Use strip_tags as there should never be HTML in the path.
            // However, we need to preserve special characters like " that were
            // removed by Html::escape().
            $path = Html::decodeEntities($this->viewsTokenReplace($alter['path'], $tokens));
            // Tokens might contain <front>, so check for <front> again.
            if ($path != '<front>') {
                $path = strip_tags($path);
            }
            // Tokens might have resolved URL's, as is the case for tokens provided by
            // Link fields, so all internal paths will be prefixed by base_path(). For
            // proper further handling reset this to internal:/.
            if (strpos($path, base_path()) === 0) {
                $path = 'internal:/' . substr($path, strlen(base_path()));
            }
            // If we have no $path and no $alter['url'], we have nothing to work with,
            // so we just return the text.
            if (empty($path) && empty($alter['url'])) {
                return $text;
            }
            // If no scheme is provided in the $path, assign the default 'http://'.
            // This allows a URL of 'www.example.com' to be converted to
            // 'http://www.example.com'.
            // Only do this when flag for external has been set, $path doesn't contain
            // a scheme and $path doesn't have a leading /.
            if ($alter['external'] && !parse_url($path, PHP_URL_SCHEME) && strpos($path, '/') !== 0) {
                // There is no scheme, add the default 'http://' to the $path.
                $path = "http://" . $path;
            }
        }
        if (empty($alter['url'])) {
            if (!parse_url($path, PHP_URL_SCHEME)) {
                // @todo Views should expect and store a leading /. See
                //   https://www.drupal.org/node/2423913.
                $alter['url'] = CoreUrl::fromUserInput('/' . ltrim($path, '/'));
            }
            else {
                $alter['url'] = CoreUrl::fromUri($path);
            }
        }
        $options = $alter['url']->getOptions() + $options;
        $path = $alter['url']->setOptions($options)
            ->toUriString();
        if (!empty($alter['path_case']) && $alter['path_case'] != 'none' && !$alter['url']->isRouted()) {
            $path = str_replace($alter['path'], $this->caseTransform($alter['path'], $this->options['alter']['path_case']), $path);
        }
        if (!empty($alter['replace_spaces'])) {
            $path = str_replace(' ', '-', $path);
        }
        // Parse the URL and move any query and fragment parameters out of the path.
        $url = UrlHelper::parse($path);
        // Seriously malformed URLs may return FALSE or empty arrays.
        if (empty($url)) {
            return $text;
        }
        // If the path is empty do not build a link around the given text and return
        // it as is.
        // http://www.example.com URLs will not have a $url['path'], so check host as well.
        if (empty($url['path']) && empty($url['host']) && empty($url['fragment']) && empty($url['url'])) {
            return $text;
        }
        // If we get to here we have a path from the URL parsing. So assign that to
        // $path now so we don't get query strings or fragments in the path.
        $path = $url['path'];
        if (isset($url['query'])) {
            // Remove query parameters that were assigned a query string replacement
            // token for which there is no value available.
            foreach ($url['query'] as $param => $val) {
                if ($val == '%' . $param) {
                    unset($url['query'][$param]);
                }
                // Replace any empty query params from URL parsing with NULL. So the
                // query will get built correctly with only the param key.
                // @see \Drupal\Component\Utility\UrlHelper::buildQuery().
                if ($val === '') {
                    $url['query'][$param] = NULL;
                }
            }
            $options['query'] = $url['query'];
        }
        if (isset($url['fragment'])) {
            $path = strtr($path, [
                '#' . $url['fragment'] => '',
            ]);
            // If the path is empty we want to have a fragment for the current site.
            if ($path == '') {
                $options['external'] = TRUE;
            }
            $options['fragment'] = $url['fragment'];
        }
        $alt = $this->viewsTokenReplace($alter['alt'], $tokens);
        // Set the title attribute of the link only if it improves accessibility
        if ($alt && $alt != $text) {
            $options['attributes']['title'] = Html::decodeEntities($alt);
        }
        $class = $this->viewsTokenReplace($alter['link_class'], $tokens);
        if ($class) {
            $options['attributes']['class'] = [
                $class,
            ];
        }
        if (!empty($alter['rel']) && ($rel = $this->viewsTokenReplace($alter['rel'], $tokens))) {
            $options['attributes']['rel'] = $rel;
        }
        $target = trim($this->viewsTokenReplace($alter['target'], $tokens));
        if (!empty($target)) {
            $options['attributes']['target'] = $target;
        }
        // Allow the addition of arbitrary attributes to links. Additional attributes
        // currently can only be altered in preprocessors and not within the UI.
        if (isset($alter['link_attributes']) && is_array($alter['link_attributes'])) {
            foreach ($alter['link_attributes'] as $key => $attribute) {
                if (!isset($options['attributes'][$key])) {
                    $options['attributes'][$key] = $this->viewsTokenReplace($attribute, $tokens);
                }
            }
        }
        // If the query and fragment were programmatically assigned overwrite any
        // parsed values.
        if (isset($alter['query'])) {
            // Convert the query to a string, perform token replacement, and then
            // convert back to an array form for
            // \Drupal\Core\Utility\LinkGeneratorInterface::generate().
            $options['query'] = UrlHelper::buildQuery($alter['query']);
            $options['query'] = $this->viewsTokenReplace($options['query'], $tokens);
            $query = [];
            parse_str($options['query'], $query);
            $options['query'] = $query;
        }
        if (isset($alter['alias'])) {
            // Alias is a boolean field, so no token.
            $options['alias'] = $alter['alias'];
        }
        if (isset($alter['fragment'])) {
            $options['fragment'] = $this->viewsTokenReplace($alter['fragment'], $tokens);
        }
        if (isset($alter['language'])) {
            $options['language'] = $alter['language'];
        }
        // If the URL came from entity_uri(), pass along the required options.
        if (isset($alter['entity'])) {
            $options['entity'] = $alter['entity'];
        }
        if (isset($alter['entity_type'])) {
            $options['entity_type'] = $alter['entity_type'];
        }
        // The path has been heavily processed above, so it should be used as-is.
        $final_url = CoreUrl::fromUri($path, $options);
        // Build the link based on our altered Url object, adding on the optional
        // prefix and suffix
        $render = [
            '#type' => 'link',
            '#title' => $text,
            '#url' => $final_url,
        ];
        if (!empty($alter['prefix'])) {
            $render['#prefix'] = $this->viewsTokenReplace($alter['prefix'], $tokens);
        }
        if (!empty($alter['suffix'])) {
            $render['#suffix'] = $this->viewsTokenReplace($alter['suffix'], $tokens);
        }
        return $this->getRenderer()
            ->render($render);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getRenderTokens($item) {
        $tokens = [];
        if (!empty($this->view->build_info['substitutions'])) {
            $tokens = $this->view->build_info['substitutions'];
        }
        $count = 0;
        foreach ($this->displayHandler
            ->getHandlers('argument') as $arg => $handler) {
            $token = "{{ arguments.{$arg} }}";
            if (!isset($tokens[$token])) {
                $tokens[$token] = '';
            }
            // Use strip tags as there should never be HTML in the path.
            // However, we need to preserve special characters like " that
            // were removed by Html::escape().
            $tokens["{{ raw_arguments.{$arg} }}"] = isset($this->view->args[$count]) ? strip_tags(Html::decodeEntities($this->view->args[$count])) : '';
            $count++;
        }
        // Get flattened set of tokens for any array depth in query parameters.
        if ($request = $this->view
            ->getRequest()) {
            $tokens += $this->getTokenValuesRecursive($request->query
                ->all());
        }
        // Now add replacements for our fields.
        foreach ($this->displayHandler
            ->getHandlers('field') as $field => $handler) {
            
            /** @var static $handler */
            $placeholder = $handler->getFieldTokenPlaceholder();
            if (isset($handler->last_render)) {
                $tokens[$placeholder] = $handler->last_render;
            }
            else {
                $tokens[$placeholder] = '';
            }
            // We only use fields up to (and including) this one.
            if ($field == $this->options['id']) {
                break;
            }
        }
        // Store the tokens for the row so we can reference them later if necessary.
        $this->view->style_plugin->render_tokens[$this->view->row_index] = $tokens;
        $this->last_tokens = $tokens;
        if (!empty($item)) {
            $this->addSelfTokens($tokens, $item);
        }
        return $tokens;
    }
    
    /**
     * Returns a token placeholder for the current field.
     *
     * @return string
     *   A token placeholder.
     */
    protected function getFieldTokenPlaceholder() {
        return '{{ ' . $this->options['id'] . ' }}';
    }
    
    /**
     * Recursive function to add replacements for nested query string parameters.
     *
     * E.g. if you pass in the following array:
     *   array(
     *     'foo' => array(
     *       'a' => 'value',
     *       'b' => 'value',
     *     ),
     *     'bar' => array(
     *       'a' => 'value',
     *       'b' => array(
     *         'c' => value,
     *       ),
     *     ),
     *   );
     *
     * Would yield the following array of tokens:
     *   array(
     *     '%foo_a' => 'value'
     *     '%foo_b' => 'value'
     *     '%bar_a' => 'value'
     *     '%bar_b_c' => 'value'
     *   );
     *
     * @param $array
     *   An array of values.
     * @param $parent_keys
     *   An array of parent keys. This will represent the array depth.
     *
     * @return array
     *   An array of available tokens, with nested keys representative of the array structure.
     */
    protected function getTokenValuesRecursive(array $array, array $parent_keys = []) {
        $tokens = [];
        foreach ($array as $param => $val) {
            if (is_array($val)) {
                // Copy parent_keys array, so we don't affect other elements of this
                // iteration.
                $child_parent_keys = $parent_keys;
                $child_parent_keys[] = $param;
                // Get the child tokens.
                $child_tokens = $this->getTokenValuesRecursive($val, $child_parent_keys);
                // Add them to the current tokens array.
                $tokens += $child_tokens;
            }
            else {
                // Create a token key based on array element structure.
                $token_string = !empty($parent_keys) ? implode('.', $parent_keys) . '.' . $param : $param;
                $tokens['{{ arguments.' . $token_string . ' }}'] = strip_tags(Html::decodeEntities($val));
            }
        }
        return $tokens;
    }
    
    /**
     * Add any special tokens this field might use for itself.
     *
     * This method is intended to be overridden by items that generate
     * fields as a list. For example, the field that displays all terms
     * on a node might have tokens for the tid and the term.
     *
     * By convention, tokens should follow the format of {{ token__subtoken }}
     * where token is the field ID and subtoken is the field. If the
     * field ID is terms, then the tokens might be {{ terms__tid }} and
     * {{ terms__name }}.
     */
    protected function addSelfTokens(&$tokens, $item) {
    }
    
    /**
     * Document any special tokens this field might use for itself.
     *
     * @see addSelfTokens()
     */
    protected function documentSelfTokens(&$tokens) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function theme(ResultRow $values) {
        $renderer = $this->getRenderer();
        $build = [
            '#theme' => $this->themeFunctions(),
            '#view' => $this->view,
            '#field' => $this,
            '#row' => $values,
        ];
        $output = $renderer->render($build);
        // Set the bubbleable rendering metadata on $view->element. This ensures the
        // bubbleable rendering metadata of individual rendered fields is not lost.
        // @see \Drupal\Core\Render\Renderer::updateStack()
        $this->view->element = $renderer->mergeBubbleableMetadata($this->view->element, $build);
        return $output;
    }
    public function themeFunctions() {
        $themes = [];
        $hook = 'views_view_field';
        $display = $this->view->display_handler->display;
        if (!empty($display)) {
            $themes[] = $hook . '__' . $this->view->storage
                ->id() . '__' . $display['id'] . '__' . $this->options['id'];
            $themes[] = $hook . '__' . $this->view->storage
                ->id() . '__' . $display['id'];
            $themes[] = $hook . '__' . $display['id'] . '__' . $this->options['id'];
            $themes[] = $hook . '__' . $display['id'];
            if ($display['id'] != $display['display_plugin']) {
                $themes[] = $hook . '__' . $this->view->storage
                    ->id() . '__' . $display['display_plugin'] . '__' . $this->options['id'];
                $themes[] = $hook . '__' . $this->view->storage
                    ->id() . '__' . $display['display_plugin'];
                $themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->options['id'];
                $themes[] = $hook . '__' . $display['display_plugin'];
            }
        }
        $themes[] = $hook . '__' . $this->view->storage
            ->id() . '__' . $this->options['id'];
        $themes[] = $hook . '__' . $this->view->storage
            ->id();
        $themes[] = $hook . '__' . $this->options['id'];
        $themes[] = $hook;
        return $themes;
    }
    public function adminLabel($short = FALSE) {
        return $this->getField(parent::adminLabel($short));
    }
    
    /**
     * Trims the field down to the specified length.
     *
     * @param array $alter
     *   The alter array of options to use.
     *     - max_length: Maximum length of the string, the rest gets truncated.
     *     - word_boundary: Trim only on a word boundary.
     *     - ellipsis: Show an ellipsis (…) at the end of the trimmed string.
     *     - html: Make sure that the html is correct.
     * @param string $value
     *   The string which should be trimmed.
     *
     * @return string
     *   The trimmed string.
     */
    public static function trimText($alter, $value) {
        if (mb_strlen($value) > $alter['max_length']) {
            $value = mb_substr($value, 0, $alter['max_length']);
            if (!empty($alter['word_boundary'])) {
                $regex = "(.*)\\b.+";
                if (function_exists('mb_ereg')) {
                    mb_regex_encoding('UTF-8');
                    $found = mb_ereg($regex, $value, $matches);
                }
                else {
                    $found = preg_match("/{$regex}/us", $value, $matches);
                }
                if ($found) {
                    $value = $matches[1];
                }
            }
            // Remove scraps of HTML entities from the end of a strings
            $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value));
            if (!empty($alter['ellipsis'])) {
                $value .= new TranslatableMarkup('…');
            }
        }
        if (!empty($alter['html'])) {
            $value = Html::normalize($value);
        }
        return $value;
    }
    
    /**
     * Gets the link generator.
     *
     * @return \Drupal\Core\Utility\LinkGeneratorInterface
     */
    protected function linkGenerator() {
        if (!isset($this->linkGenerator)) {
            $this->linkGenerator = \Drupal::linkGenerator();
        }
        return $this->linkGenerator;
    }
    
    /**
     * Returns the render API renderer.
     *
     * @return \Drupal\Core\Render\RendererInterface
     */
    protected function getRenderer() {
        if (!isset($this->renderer)) {
            $this->renderer = \Drupal::service('renderer');
        }
        return $this->renderer;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
FieldPluginBase::$additional_fields public property Stores additional fields which get added to the query.
FieldPluginBase::$aliases public property
FieldPluginBase::$field_alias public property
FieldPluginBase::$lastRenderIndex protected property Keeps track of the last render index.
FieldPluginBase::$linkGenerator protected property The link generator.
FieldPluginBase::$original_value public property The field value prior to any rewriting.
FieldPluginBase::$renderer protected property Stores the render API renderer. Overrides PluginBase::$renderer 1
FieldPluginBase::addAdditionalFields protected function Add &#039;additional&#039; fields to the query.
FieldPluginBase::addSelfTokens protected function Add any special tokens this field might use for itself. 4
FieldPluginBase::adminLabel public function Return a string representing this handler&#039;s name in the UI. Overrides HandlerBase::adminLabel
FieldPluginBase::adminSummary public function Provide extra data to the administration form. Overrides HandlerBase::adminSummary
FieldPluginBase::advancedRender public function Renders a field using advanced settings. Overrides FieldHandlerInterface::advancedRender
FieldPluginBase::allowAdvancedRender protected function Determine if this field can allow advanced rendering.
FieldPluginBase::buildOptionsForm public function Default option form that provides label widget that all fields should have. Overrides HandlerBase::buildOptionsForm 25
FieldPluginBase::clickSort public function Adds an ORDER BY clause to the query for click sort columns. Overrides FieldHandlerInterface::clickSort 1
FieldPluginBase::clickSortable public function Determines if this field is click sortable. Overrides FieldHandlerInterface::clickSortable 5
FieldPluginBase::defineOptions protected function Information about options for all kinds of purposes will be held here. Overrides HandlerBase::defineOptions 26
FieldPluginBase::documentSelfTokens protected function Document any special tokens this field might use for itself. 3
FieldPluginBase::elementClasses public function Returns the class of the field. Overrides FieldHandlerInterface::elementClasses
FieldPluginBase::elementLabelClasses public function Returns the class of the field&#039;s label. Overrides FieldHandlerInterface::elementLabelClasses
FieldPluginBase::elementLabelType public function Returns an HTML element for the label based upon the field&#039;s element type. Overrides FieldHandlerInterface::elementLabelType
FieldPluginBase::elementType public function Returns an HTML element based upon the field&#039;s element type. Overrides FieldHandlerInterface::elementType 1
FieldPluginBase::elementWrapperClasses public function Returns the class of the field&#039;s wrapper. Overrides FieldHandlerInterface::elementWrapperClasses
FieldPluginBase::elementWrapperType public function Returns an HTML element for the wrapper based upon the field&#039;s element type. Overrides FieldHandlerInterface::elementWrapperType
FieldPluginBase::getElements public function Provides a list of elements valid for field HTML. Overrides FieldHandlerInterface::getElements
FieldPluginBase::getEntity public function Gets the entity matching the current row and relationship. Overrides FieldHandlerInterface::getEntity
FieldPluginBase::getFieldTokenPlaceholder protected function Returns a token placeholder for the current field.
FieldPluginBase::getPreviousFieldLabels protected function Returns all field labels of fields before this field.
FieldPluginBase::getRenderer protected function Returns the render API renderer. Overrides PluginBase::getRenderer
FieldPluginBase::getRenderTokens public function Gets the &#039;render&#039; tokens to use for advanced rendering. Overrides FieldHandlerInterface::getRenderTokens
FieldPluginBase::getTokenValuesRecursive protected function Recursive function to add replacements for nested query string parameters.
FieldPluginBase::getValue public function Gets the value that&#039;s supposed to be rendered. Overrides FieldHandlerInterface::getValue 2
FieldPluginBase::init public function Initialize the plugin. Overrides HandlerBase::init 13
FieldPluginBase::isValueEmpty public function Checks if a field value is empty. Overrides FieldHandlerInterface::isValueEmpty
FieldPluginBase::label public function Gets this field&#039;s label. Overrides FieldHandlerInterface::label
FieldPluginBase::linkGenerator protected function Gets the link generator.
FieldPluginBase::postRender public function Runs after every field has been rendered. Overrides FieldHandlerInterface::postRender
FieldPluginBase::preRender public function Runs before any fields are rendered. Overrides FieldHandlerInterface::preRender 10
FieldPluginBase::query public function Called to add the field to a query. Overrides HandlerBase::query 19
FieldPluginBase::render public function Renders the field. Overrides FieldHandlerInterface::render 26
FieldPluginBase::renderAltered protected function Render this field as user-defined altered text.
FieldPluginBase::renderAsLink protected function Render this field as a link, with the info from a fieldset set by the user.
FieldPluginBase::renderText public function Performs an advanced text render for the item. Overrides FieldHandlerInterface::renderText
FieldPluginBase::renderTrimText protected function Trims the field down to the specified length.
FieldPluginBase::RENDER_TEXT_PHASE_COMPLETELY constant Indicator of the renderText() method for rendering the whole element.
FieldPluginBase::RENDER_TEXT_PHASE_EMPTY constant Indicator of the renderText() method for rendering the empty text.
FieldPluginBase::RENDER_TEXT_PHASE_SINGLE_ITEM constant Indicator of the renderText() method for rendering a single item.
FieldPluginBase::submitOptionsForm public function Performs some cleanup tasks on the options array before saving it. Overrides PluginBase::submitOptionsForm 1
FieldPluginBase::theme public function Renders row values using $this-&gt;themeFunctions() as #theme. Overrides FieldHandlerInterface::theme
FieldPluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. Overrides PluginBase::themeFunctions
FieldPluginBase::tokenizeValue public function Replaces a value with tokens from the last field. Overrides FieldHandlerInterface::tokenizeValue
FieldPluginBase::trimText public static function Trims the field down to the specified length.
FieldPluginBase::useStringGroupBy public function Determines if this field can be grouped in the results. Overrides FieldHandlerInterface::useStringGroupBy
HandlerBase::$field public property With field you can override the realField if the real field is not set.
HandlerBase::$moduleHandler protected property The module handler. 3
HandlerBase::$query public property Where the $query object will reside. 7
HandlerBase::$realField public property The real field.
HandlerBase::$relationship public property The relationship used for this field.
HandlerBase::$table public property The table this handler is attached to.
HandlerBase::$tableAlias public property The alias of the table of this handler which is used in the query.
HandlerBase::$viewsData protected property The views data service.
HandlerBase::acceptExposedInput public function Take input from exposed handlers and assign to this handler, if necessary. 1
HandlerBase::access public function Check whether given user has access to this handler. Overrides ViewsHandlerInterface::access 4
HandlerBase::breakString public static function Breaks x,y,z and x+y+z into an array. Overrides ViewsHandlerInterface::breakString
HandlerBase::broken public function Determines if the handler is considered &#039;broken&#039;. Overrides ViewsHandlerInterface::broken
HandlerBase::buildExposedForm public function Render our chunk of the exposed handler form when selecting. 1
HandlerBase::buildExposeForm public function Form for exposed handler options. 2
HandlerBase::buildExtraOptionsForm public function Provide a form for setting options. 1
HandlerBase::buildGroupByForm public function Provide a form for aggregation settings. 1
HandlerBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides PluginBase::calculateDependencies 10
HandlerBase::canExpose public function Determine if a handler can be exposed. 2
HandlerBase::caseTransform protected function Transform a string by a certain method.
HandlerBase::defaultExposeOptions public function Set new exposed option defaults when exposed setting is flipped on. 2
HandlerBase::defineExtraOptions public function Provide defaults for the handler.
HandlerBase::displayExposedForm public function Displays the Expose form.
HandlerBase::ensureMyTable public function Ensures that the main table for this handler is in the query. Overrides ViewsHandlerInterface::ensureMyTable 2
HandlerBase::exposedInfo public function Get information about the exposed form for the form renderer. 1
HandlerBase::getDateField public function Creates cross-database SQL dates. 2
HandlerBase::getDateFormat public function Creates cross-database SQL date formatting. 2
HandlerBase::getEntityType public function Determines the entity type used by this handler. Overrides ViewsHandlerInterface::getEntityType
HandlerBase::getField public function Shortcut to get a handler&#039;s raw field value. Overrides ViewsHandlerInterface::getField
HandlerBase::getJoin public function Get the join object that should be used for this handler. Overrides ViewsHandlerInterface::getJoin
HandlerBase::getModuleHandler protected function Gets the module handler.
HandlerBase::getTableJoin public static function Fetches a handler to join one table to a primary table from the data cache. Overrides ViewsHandlerInterface::getTableJoin
HandlerBase::getViewsData protected function Gets views data service.
HandlerBase::hasExtraOptions public function Determines if the handler has extra options. 1
HandlerBase::isAGroup public function Returns TRUE if the exposed filter works like a grouped filter. 1
HandlerBase::isExposed public function Determine if this item is &#039;exposed&#039;.
HandlerBase::multipleExposedInput public function Define if the exposed input has to be submitted multiple times. 1
HandlerBase::placeholder protected function Provides a unique placeholders for handlers.
HandlerBase::postExecute public function Run after the view is executed, before the result is cached. Overrides ViewsHandlerInterface::postExecute
HandlerBase::preQuery public function Run before the view is built. Overrides ViewsHandlerInterface::preQuery 2
HandlerBase::sanitizeValue public function Sanitize the value for output. Overrides ViewsHandlerInterface::sanitizeValue
HandlerBase::setModuleHandler public function Sets the module handler.
HandlerBase::setRelationship public function Sets up any needed relationship. Overrides ViewsHandlerInterface::setRelationship
HandlerBase::setViewsData public function
HandlerBase::showExposeButton public function Shortcut to display the expose/hide button. 2
HandlerBase::showExposeForm public function Shortcut to display the exposed options form. Overrides ViewsHandlerInterface::showExposeForm
HandlerBase::storeExposedInput public function If set to remember exposed input in the session, store it there. 1
HandlerBase::submitExposed public function Submit the exposed handler form.
HandlerBase::submitExposeForm public function Perform any necessary changes to the form exposes prior to storage.
HandlerBase::submitExtraOptionsForm public function Perform any necessary changes to the form values prior to storage.
HandlerBase::submitFormCalculateOptions public function Calculates options stored on the handler. 1
HandlerBase::submitGroupByForm public function Perform any necessary changes to the form values prior to storage. 1
HandlerBase::submitTemporaryForm public function Submits a temporary form.
HandlerBase::usesGroupBy public function Provides the handler some groupby. 13
HandlerBase::validate public function Validate that the plugin is correct and can be saved. Overrides PluginBase::validate 2
HandlerBase::validateExposed public function Validate the exposed handler form. 4
HandlerBase::validateExposeForm public function Validate the options form. 2
HandlerBase::validateExtraOptionsForm public function Validate the options form.
HandlerBase::__construct public function Constructs a Handler object. Overrides PluginBase::__construct 45
PluginBase::$definition public property Plugins&#039; 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::$usesOptions protected property Denotes whether the plugin has an additional options form. 8
PluginBase::$view public property The top object of a view. 1
PluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 63
PluginBase::destroy public function Clears a plugin. Overrides ViewsPluginInterface::destroy 2
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::getProvider public function Returns the plugin provider. Overrides ViewsPluginInterface::getProvider
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::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::summaryTitle public function Returns the summary of the settings in the display. Overrides ViewsPluginInterface::summaryTitle 6
PluginBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks 6
PluginBase::unpackOptions public function Unpacks options over our existing defaults. Overrides ViewsPluginInterface::unpackOptions
PluginBase::usesOptions public function Returns the usesOptions property. Overrides ViewsPluginInterface::usesOptions 8
PluginBase::validateOptionsForm public function Validate the options form. Overrides ViewsPluginInterface::validateOptionsForm 15
PluginBase::viewsTokenReplace protected function Replaces Views&#039; tokens in a given string. 1
PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT constant Query string to indicate the site default language.
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
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.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.