abstract class PrerenderList in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/field/PrerenderList.php \Drupal\views\Plugin\views\field\PrerenderList
- 9 core/modules/views/src/Plugin/views/field/PrerenderList.php \Drupal\views\Plugin\views\field\PrerenderList
Field handler to provide a list of items.
The items are expected to be loaded by a child object during preRender, and 'my field' is expected to be the pointer to the items in the list.
Items to render should be in a list in $this->items
Hierarchy
- class \Drupal\views\Plugin\views\field\PrerenderList extends \Drupal\views\Plugin\views\field\FieldPluginBase implements MultiItemsFieldHandlerInterface
Expanded class hierarchy of PrerenderList
3 files declare their use of PrerenderList
- Permissions.php in core/
modules/ user/ src/ Plugin/ views/ field/ Permissions.php - Roles.php in core/
modules/ user/ src/ Plugin/ views/ field/ Roles.php - TaxonomyIndexTid.php in core/
modules/ taxonomy/ src/ Plugin/ views/ field/ TaxonomyIndexTid.php
File
- core/
modules/ views/ src/ Plugin/ views/ field/ PrerenderList.php, line 18
Namespace
Drupal\views\Plugin\views\fieldView source
abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldHandlerInterface {
/**
* Stores all items which are used to render the items.
*
* It should be keyed first by the id of the base table, for example nid.
* The second key is the id of the thing which is displayed multiple times
* per row, for example the tid.
*
* @var array
*/
public $items = [];
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['type'] = [
'default' => 'separator',
];
$options['separator'] = [
'default' => ', ',
];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['type'] = [
'#type' => 'radios',
'#title' => $this
->t('Display type'),
'#options' => [
'ul' => $this
->t('Unordered list'),
'ol' => $this
->t('Ordered list'),
'separator' => $this
->t('Simple separator'),
],
'#default_value' => $this->options['type'],
];
$form['separator'] = [
'#type' => 'textfield',
'#title' => $this
->t('Separator'),
'#default_value' => $this->options['separator'],
'#states' => [
'visible' => [
':input[name="options[type]"]' => [
'value' => 'separator',
],
],
],
];
parent::buildOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function renderItems($items) {
if (!empty($items)) {
if ($this->options['type'] == 'separator') {
$render = [
'#type' => 'inline_template',
'#template' => '{{ items|safe_join(separator) }}',
'#context' => [
'items' => $items,
'separator' => $this
->sanitizeValue($this->options['separator'], 'xss_admin'),
],
];
}
else {
$render = [
'#theme' => 'item_list',
'#items' => $items,
'#title' => NULL,
'#list_type' => $this->options['type'],
];
}
return \Drupal::service('renderer')
->render($render);
}
}
/**
* {@inheritdoc}
*
* Items should be stored in the result array, if possible, as an array
* with 'value' as the actual displayable value of the item, plus
* any items that might be found in the 'alter' options array for
* creating links, such as 'path', 'fragment', 'query' etc, such a thing
* is to be made. Additionally, items that might be turned into tokens
* should also be in this array.
*/
public function getItems(ResultRow $values) {
$field = $this
->getValue($values);
if (!empty($this->items[$field])) {
return $this->items[$field];
}
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DerivativeInspectionInterface:: |
public | function | Gets the base_plugin_id of the plugin instance. | |
DerivativeInspectionInterface:: |
public | function | Gets the derivative_id of the plugin instance. | |
FieldHandlerInterface:: |
public | function | Renders a field using advanced settings. | |
FieldHandlerInterface:: |
public | function | Adds an ORDER BY clause to the query for click sort columns. | |
FieldHandlerInterface:: |
public | function | Determines if this field is click sortable. | |
FieldHandlerInterface:: |
public | function | Returns the class of the field. | |
FieldHandlerInterface:: |
public | function | Returns the class of the field's label. | |
FieldHandlerInterface:: |
public | function | Returns an HTML element for the label based upon the field's element type. | |
FieldHandlerInterface:: |
public | function | Returns an HTML element based upon the field's element type. | |
FieldHandlerInterface:: |
public | function | Returns the class of the field's wrapper. | |
FieldHandlerInterface:: |
public | function | Returns an HTML element for the wrapper based upon the field's element type. | |
FieldHandlerInterface:: |
public | function | Provides a list of elements valid for field HTML. | |
FieldHandlerInterface:: |
public | function | Gets the entity matching the current row and relationship. | |
FieldHandlerInterface:: |
public | function | Gets the 'render' tokens to use for advanced rendering. | |
FieldHandlerInterface:: |
public | function | Gets the value that's supposed to be rendered. | |
FieldHandlerInterface:: |
public | function | Checks if a field value is empty. | |
FieldHandlerInterface:: |
public | function | Gets this field's label. | |
FieldHandlerInterface:: |
public | function | Runs after every field has been rendered. | |
FieldHandlerInterface:: |
public | function | Runs before any fields are rendered. | 3 |
FieldHandlerInterface:: |
public | function | Renders the field. | |
FieldHandlerInterface:: |
public | function | Performs an advanced text render for the item. | |
FieldHandlerInterface:: |
public | function | Renders row values using $this->themeFunctions() as #theme. | |
FieldHandlerInterface:: |
public | function | Replaces a value with tokens from the last field. | |
FieldHandlerInterface:: |
public | function | Determines if this field will be available as an option to group the result by in the style settings. | |
MultiItemsFieldHandlerInterface:: |
public | function | Renders a single item of a row. | 3 |
PluginInspectionInterface:: |
public | function | Gets the definition of the plugin implementation. | 1 |
PluginInspectionInterface:: |
public | function | Gets the plugin_id of the plugin instance. | 1 |
PrerenderList:: |
public | property | Stores all items which are used to render the items. | |
PrerenderList:: |
public | function |
Provide a form to edit options for this plugin. Overrides ViewsPluginInterface:: |
1 |
PrerenderList:: |
protected | function | 1 | |
PrerenderList:: |
public | function |
Items should be stored in the result array, if possible, as an array
with 'value' as the actual displayable value of the item, plus
any items that might be found in the 'alter' options array for
creating links, such as… Overrides MultiItemsFieldHandlerInterface:: |
|
PrerenderList:: |
public | function |
Render all items in this field together. Overrides MultiItemsFieldHandlerInterface:: |
|
ViewsHandlerInterface:: |
public | function | Check whether given user has access to this handler. | |
ViewsHandlerInterface:: |
public | function | Return a string representing this handler's name in the UI. | |
ViewsHandlerInterface:: |
public | function | Provide text for the administrative summary. | |
ViewsHandlerInterface:: |
public static | function | Breaks x,y,z and x+y+z into an array. | |
ViewsHandlerInterface:: |
public | function | Determines if the handler is considered 'broken', meaning it's a placeholder used when a handler can't be found. | |
ViewsHandlerInterface:: |
public | function | Ensure the main table for this handler is in the query. This is used a lot. | |
ViewsHandlerInterface:: |
public | function | Determines the entity type used by this handler. | |
ViewsHandlerInterface:: |
public | function | Shortcut to get a handler's raw field value. | |
ViewsHandlerInterface:: |
public | function | Get the join object that should be used for this handler. | |
ViewsHandlerInterface:: |
public static | function | Fetches a handler to join one table to a primary table from the data cache. | |
ViewsHandlerInterface:: |
public | function | Run after the view is executed, before the result is cached. | |
ViewsHandlerInterface:: |
public | function | Run before the view is built. | |
ViewsHandlerInterface:: |
public | function | Sanitize the value for output. | |
ViewsHandlerInterface:: |
public | function | Called just prior to query(), this lets a handler set up any relationship it needs. | |
ViewsHandlerInterface:: |
public | function | Shortcut to display the exposed options form. | |
ViewsPluginInterface:: |
public static | function | 3 | |
ViewsPluginInterface:: |
public | function | Clears a plugin. | |
ViewsPluginInterface:: |
public | function | Filter out stored options depending on the defined options. | |
ViewsPluginInterface:: |
public | function | Returns an array of available token replacements. | |
ViewsPluginInterface:: |
public | function | Returns the plugin provider. | |
ViewsPluginInterface:: |
public | function | Adds elements for available core tokens to a form. | |
ViewsPluginInterface:: |
public | function | Returns a string with any core tokens replaced. | |
ViewsPluginInterface:: |
public | function | Initialize the plugin. | 3 |
ViewsPluginInterface:: |
public | function | Return the human readable name of the display. | |
ViewsPluginInterface:: |
public static | function | Moves form elements into fieldsets for presentation purposes. | |
ViewsPluginInterface:: |
public static | function | Flattens the structure of form elements. | |
ViewsPluginInterface:: |
public | function | Add anything to the query that we might need to. | 3 |
ViewsPluginInterface:: |
public | function | Handle any special handling on the validate form. | |
ViewsPluginInterface:: |
public | function | Returns the summary of the settings in the display. | |
ViewsPluginInterface:: |
public | function | Provide a full list of possible theme templates used by this style. | |
ViewsPluginInterface:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
ViewsPluginInterface:: |
public | function | Returns the usesOptions property. | |
ViewsPluginInterface:: |
public | function | Validate that the plugin is correct and can be saved. | |
ViewsPluginInterface:: |
public | function | Validate the options form. |