class MediaLibrarySelectForm extends FieldPluginBase (View source)

internal  Plugin classes are internal.
 

Defines a field that outputs a checkbox and form for selecting media.

Traits

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Provides dependency injection friendly methods for serialization.

Provides a trait for the messenger service.

Constants

DERIVATIVE_SEPARATOR

A string which is used to separate base plugin IDs from the derivative ID.

INCLUDE_NEGOTIATED

Include negotiated languages when listing languages.

INCLUDE_ENTITY

Include entity row languages when listing languages.

VIEWS_QUERY_LANGUAGE_SITE_DEFAULT

Query string to indicate the site default language.

RENDER_TEXT_PHASE_SINGLE_ITEM

Indicator of the renderText() method for rendering a single item.

(If no render_item() is present).

RENDER_TEXT_PHASE_COMPLETELY

Indicator of the renderText() method for rendering the whole element.

(if no render_item() method is available).

RENDER_TEXT_PHASE_EMPTY

Indicator of the renderText() method for rendering the empty text.

Properties

protected string $pluginId

The plugin_id.

from  PluginBase
protected array $pluginDefinition

The plugin implementation definition.

from  PluginBase
protected array $configuration

Configuration information passed into the plugin.

from  PluginBase
protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected MessengerInterface $messenger

The messenger.

from  MessengerTrait
array $options

Options for this plugin will be held here.

from  PluginBase
ViewExecutable $view

The top object of a view.

from  PluginBase
DisplayPluginBase $displayHandler

The display object this plugin is for.

from  PluginBase
array $definition

Plugins's definition.

from  PluginBase
protected bool $usesOptions

Denotes whether the plugin has an additional options form.

from  PluginBase
protected RendererInterface $renderer

Stores the render API renderer.

from  FieldPluginBase
QueryPluginBase $query

Where the $query object will reside.

from  HandlerBase
string $table

The table this handler is attached to.

from  HandlerBase
string $tableAlias

The alias of the table of this handler which is used in the query.

from  HandlerBase
string $realField

The actual field in the database table, maybe different on other kind of query plugins/special handlers.

from  HandlerBase
string $field

With field you can override the realField if the real field is not set.

from  HandlerBase
string $relationship

The relationship used for this field.

from  HandlerBase
protected ModuleHandlerInterface $moduleHandler

The module handler.

from  HandlerBase
protected ViewsData $viewsData

The views data service.

from  HandlerBase
string $field_alias from  FieldPluginBase
$aliases from  FieldPluginBase
mixed $original_value

The field value prior to any rewriting.

from  FieldPluginBase
array $additional_fields

Stores additional fields which get added to the query.

from  FieldPluginBase
protected LinkGeneratorInterface $linkGenerator

The link generator.

from  FieldPluginBase
protected int|null $lastRenderIndex

Keeps track of the last render index.

from  FieldPluginBase

Methods

__construct(array $configuration, string $plugin_id, mixed $plugin_definition)

Constructs a Handler object.

string
getPluginId()

Gets the plugin_id of the plugin instance.

string
getBaseId()

Gets the base_plugin_id of the plugin instance.

string|null
getDerivativeId()

Gets the derivative_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

bool
isConfigurable()

Determines if the plugin is configurable.

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

setMessenger(MessengerInterface $messenger)

Sets the messenger.

messenger()

Gets the messenger.

create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

init(ViewExecutable $view, DisplayPluginBase $display, array $options = NULL)

Initialize the plugin.

array
defineOptions()

Information about options for all kinds of purposes will be held here.

setOptionDefaults(array $storage, array $options)

Fills up the options of the plugin with defaults.

filterByDefinedOptions(array $storage)

Filter out stored options depending on the defined options.

doFilterByDefinedOptions(array $storage, array $options)

Do the work to filter out stored options depending on the defined options.

unpackOptions($storage, $options, $definition = NULL, $all = TRUE, $check = TRUE)

Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.

destroy()

Clears a plugin.

buildOptionsForm($form, FormStateInterface $form_state)

Default options form that provides the label widget that all fields should have.

static string[]
trustedCallbacks()

Lists the trusted callbacks provided by the implementing class.

validateOptionsForm($form, FormStateInterface $form_state)

Validate the options form.

submitOptionsForm($form, FormStateInterface $form_state)

Performs some cleanup tasks on the options array before saving it.

query()

Called to add the field to a query.

themeFunctions()

Provide a full list of possible theme templates used by this style.

An
validate()

Validate that the plugin is correct and can be saved.

summaryTitle()

Returns the summary of the settings in the display.

pluginTitle()

Return the human readable name of the display.

usesOptions()

Returns the usesOptions property.

string
globalTokenReplace(string $string = '', array $options = [])

Returns a string with any core tokens replaced.

string
viewsTokenReplace($text, $tokens)

Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin.

array
getAvailableGlobalTokens(bool $prepared = FALSE, array $types = [])

Returns an array of available token replacements.

globalTokenForm(array $form, FormStateInterface $form_state)

Adds elements for available core tokens to a form.

static array
preRenderAddFieldsetMarkup(array $form)

Moves form elements into fieldsets for presentation purposes.

static array
preRenderFlattenData(array $form)

Flattens the structure of form elements.

array
calculateDependencies()

Calculates dependencies for the configured plugin.

string
getProvider()

Returns the plugin provider.

array
listLanguages(int $flags = LanguageInterface::STATE_ALL, array $current_values = NULL)

Makes an array of languages, optionally including special languages.

static array
queryLanguageSubstitutions()

Returns substitutions for Views queries for languages.

getRenderer()

Returns the render API renderer.

adminLabel($short = FALSE)

Return a string representing this handler's name in the UI.

getField($field = NULL)

Shortcut to get a handler's raw field value.

sanitizeValue($value, $type = NULL)

Sanitize the value for output.

string
caseTransform($string, $option)

Transform a string by a certain method.

getModuleHandler()

Gets the module handler.

setModuleHandler(ModuleHandlerInterface $module_handler)

Sets the module handler.

usesGroupBy()

Provides the handler some groupby.

buildGroupByForm($form, FormStateInterface $form_state)

Provide a form for aggregation settings.

submitGroupByForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form values prior to storage.

hasExtraOptions()

If a handler has 'extra options' it will get a little settings widget and another form called extra_options.

defineExtraOptions($option)

Provide defaults for the handler.

buildExtraOptionsForm($form, FormStateInterface $form_state)

Provide a form for setting options.

validateExtraOptionsForm($form, FormStateInterface $form_state)

Validate the options form.

submitExtraOptionsForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form values prior to storage.

canExpose()

Determine if a handler can be exposed.

defaultExposeOptions()

Set new exposed option defaults when exposed setting is flipped on.

exposedInfo()

Get information about the exposed form for the form renderer.

buildExposedForm($form, FormStateInterface $form_state)

Render our chunk of the exposed handler form when selecting.

validateExposed($form, FormStateInterface $form_state)

Validate the exposed handler form.

submitExposed($form, FormStateInterface $form_state)

Submit the exposed handler form.

buildExposeForm($form, FormStateInterface $form_state)

Form for exposed handler options.

validateExposeForm($form, FormStateInterface $form_state)

Validate the options form.

submitExposeForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form exposes prior to storage.

showExposeButton($form, FormStateInterface $form_state)

Shortcut to display the expose/hide button.

showExposeForm($form, FormStateInterface $form_state)

Shortcut to display the exposed options form.

bool
access(AccountInterface $account)

Check whether given user has access to this handler.

preQuery()

Run before the view is built.

postExecute($values)

Run after the view is executed, before the result is cached.

string
placeholder()

Provides a unique placeholders for handlers.

setRelationship()

Called just prior to query(), this lets a handler set up any relationship it needs.

ensureMyTable()

Ensure the main table for this handler is in the query. This is used a lot.

adminSummary()

Provide extra data to the administration form.

bool
isExposed()

Determine if this item is 'exposed', meaning it provides form elements to let users modify the view.

isAGroup()

Returns TRUE if the exposed filter works like a grouped filter.

multipleExposedInput()

Define if the exposed input has to be submitted multiple times.

acceptExposedInput($input)

Take input from exposed handlers and assign to this handler, if necessary.

storeExposedInput($input, $status)

If set to remember exposed input in the session, store it there.

getJoin()

Get the join object that should be used for this handler.

broken()

Determines if the handler is considered 'broken', meaning it's a placeholder used when a handler can't be found.

string
getDateFormat(string $format)

Creates cross-database SQL date formatting.

string
getDateField()

Creates cross-database SQL dates.

getViewsData()

Gets views data service.

setViewsData(ViewsData $views_data)

{@inheritdoc}

static JoinPluginBase
getTableJoin(string $table, string $base_table)

Fetches a handler to join one table to a primary table from the data cache.

string
getEntityType()

Determines the entity type used by this handler.

static object
breakString(string $str, bool $force_int = FALSE)

Breaks x,y,z and x+y+z into an array.

displayExposedForm($form, FormStateInterface $form_state)

Displays the Expose form.

submitTemporaryForm($form, FormStateInterface $form_state)

A submit handler that is used for storing temporary items when using multi-step changes, such as ajax requests.

array
submitFormCalculateOptions(array $options, array $form_state_options)

Calculates options stored on the handler.

allowAdvancedRender()

Determine if this field can allow advanced rendering.

addAdditionalFields($fields = NULL)

Add 'additional' fields to the query.

clickSort(string $order)

Adds an ORDER BY clause to the query for click sort columns.

bool
clickSortable()

Determines if this field is click sortable.

label()

Gets this field's label.

elementType(bool $none_supported = FALSE, bool $default_empty = FALSE, bool $inline = FALSE)

Returns an HTML element based upon the field's element type.

elementLabelType(bool $none_supported = FALSE, bool $default_empty = FALSE)

Returns an HTML element for the label based upon the field's element type.

elementWrapperType(bool $none_supported = FALSE, bool $default_empty = FALSE)

Returns an HTML element for the wrapper based upon the field's element type.

getElements()

Provides a list of elements valid for field HTML.

elementClasses(bool $row_index = NULL)

Returns the class of the field.

tokenizeValue(string $value, bool $row_index = NULL)

Replaces a value with tokens from the last field.

elementLabelClasses(bool $row_index = NULL)

Returns the class of the field's label.

elementWrapperClasses(bool $row_index = NULL)

Returns the class of the field's wrapper.

getEntity(ResultRow $values)

Gets the entity matching the current row and relationship.

getValue(ResultRow $row, string $field = NULL)

Gets the value that's supposed to be rendered.

bool
useStringGroupBy()

Determines if this field will be available as an option to group the result by in the style settings.

array
getPreviousFieldLabels()

Returns all field labels of fields before this field.

preRender(ResultRow[] $values)

Runs before any fields are rendered.

render(ResultRow $values)

Renders the field.

string[]
postRender(ResultRow $row, $output)

Runs after every field has been rendered.

advancedRender(ResultRow $values)

Renders a field using advanced settings.

bool
isValueEmpty($value, bool $empty_zero, bool $no_skip_empty = TRUE)

Checks if a field value is empty.

renderText(array $alter)

Performs an advanced text render for the item.

renderAltered($alter, $tokens)

Render this field as user-defined altered text.

string
renderTrimText(array $alter, string $value)

Trims the field down to the specified length.

renderAsLink($alter, $text, $tokens)

Render this field as a link, with the info from a fieldset set by the user.

array
getRenderTokens(mixed $item)

Gets the 'render' tokens to use for advanced rendering.

string
getFieldTokenPlaceholder()

Returns a token placeholder for the current field.

An
getTokenValuesRecursive(array $array, array $parent_keys = [])

Recursive function to add replacements for nested query string parameters.

addSelfTokens($tokens, $item)

Add any special tokens this field might use for itself.

documentSelfTokens($tokens)

Document any special tokens this field might use for itself.

theme(ResultRow $values)

Renders row values using $this->themeFunctions() as #theme.

static string
trimText(array $alter, string $value)

Trims the field down to the specified length.

linkGenerator()

Gets the link generator.

viewsForm(array $form, FormStateInterface $form_state)

Form constructor for the media library select form.

static AjaxResponse
updateWidget(array $form, FormStateInterface $form_state, Request $request)

Submit handler for the media library select form.

viewsFormValidate(array $form, FormStateInterface $form_state)

{@inheritdoc}

Details

__construct(array $configuration, string $plugin_id, mixed $plugin_definition)

Constructs a Handler object.

Parameters

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin_id for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

string getBaseId()

Gets the base_plugin_id of the plugin instance.

Return Value

string

The base_plugin_id of the plugin instance.

string|null getDerivativeId()

Gets the derivative_id of the plugin instance.

Return Value

string|null

The derivative_id of the plugin instance NULL otherwise.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

bool isConfigurable()

Determines if the plugin is configurable.

Return Value

bool

A boolean indicating whether the plugin is configurable.

protected TranslatableMarkup t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.

In order for strings to be localized, make them available in one of the ways supported by the

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

setMessenger(MessengerInterface $messenger)

Sets the messenger.

Parameters

MessengerInterface $messenger

The messenger.

MessengerInterface messenger()

Gets the messenger.

Return Value

MessengerInterface

The messenger.

static ContainerFactoryPluginInterface create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

Parameters

ContainerInterface $container

The container to pull out services used in the plugin.

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin ID for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

Return Value

ContainerFactoryPluginInterface

Returns an instance of this plugin.

init(ViewExecutable $view, DisplayPluginBase $display, array $options = NULL)

Initialize the plugin.

Parameters

ViewExecutable $view

The view object.

DisplayPluginBase $display

The display handler.

array $options

The options configured for this plugin.

protected array defineOptions()

Information about options for all kinds of purposes will be held here.

Return Value

array

Returns the options of this handler/plugin.

protected setOptionDefaults(array $storage, array $options)

Fills up the options of the plugin with defaults.

Parameters

array $storage

An array which stores the actual option values of the plugin.

array $options

An array which describes the options of a plugin. Each element is an associative array containing:

  • default: The default value of one option. Should be translated to the interface text language selected for page if translatable.
  • (optional) contains: An array which describes the available options under the key. If contains is set, the default will be ignored and assumed to be an empty array.
  • (optional) 'bool': TRUE if the value is boolean, else FALSE.

filterByDefinedOptions(array $storage)

Filter out stored options depending on the defined options.

Parameters

array $storage

The stored options.

protected doFilterByDefinedOptions(array $storage, array $options)

Do the work to filter out stored options depending on the defined options.

Parameters

array $storage

The stored options.

array $options

The defined options.

unpackOptions($storage, $options, $definition = NULL, $all = TRUE, $check = TRUE)

Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.

Parameters

$storage
$options
$definition
$all
$check

destroy()

Clears a plugin.

buildOptionsForm($form, FormStateInterface $form_state)

Default options form that provides the label widget that all fields should have.

Parameters

$form
FormStateInterface $form_state

static string[] trustedCallbacks()

Lists the trusted callbacks provided by the implementing class.

Trusted callbacks are public methods on the implementing class and can be invoked via \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback().

Return Value

string[]

List of method names implemented by the class that can be used as trusted callbacks.

validateOptionsForm($form, FormStateInterface $form_state)

Validate the options form.

Parameters

$form
FormStateInterface $form_state

submitOptionsForm($form, FormStateInterface $form_state)

Performs some cleanup tasks on the options array before saving it.

Parameters

$form
FormStateInterface $form_state

query()

Called to add the field to a query.

themeFunctions()

Provide a full list of possible theme templates used by this style.

An validate()

Validate that the plugin is correct and can be saved.

Return Value

An

array of error strings to tell the user what is wrong with this plugin.

summaryTitle()

Returns the summary of the settings in the display.

pluginTitle()

Return the human readable name of the display.

This appears on the ui beside each plugin and beside the settings link.

usesOptions()

Returns the usesOptions property.

string globalTokenReplace(string $string = '', array $options = [])

Returns a string with any core tokens replaced.

Parameters

string $string

The string to preform the token replacement on.

array $options

An array of options, as passed to \Drupal\Core\Utility\Token::replace().

Return Value

string

The tokenized string.

protected string viewsTokenReplace($text, $tokens)

Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin.

Parameters

$text

Unsanitized string with possible tokens.

$tokens

Array of token => replacement_value items.

Return Value

string

array getAvailableGlobalTokens(bool $prepared = FALSE, array $types = [])

Returns an array of available token replacements.

Parameters

bool $prepared

Whether to return the raw token info for each token or an array of prepared tokens for each type. E.g. "[view:name]".

array $types

An array of additional token types to return, defaults to 'site' and 'view'.

Return Value

array

An array of available token replacement info or tokens, grouped by type.

globalTokenForm(array $form, FormStateInterface $form_state)

Adds elements for available core tokens to a form.

Parameters

array $form

The form array to alter, passed by reference.

FormStateInterface $form_state

The current state of the form.

static array preRenderAddFieldsetMarkup(array $form)

Moves form elements into fieldsets for presentation purposes.

Many views forms use #tree = TRUE to keep their values in a hierarchy for easier storage. Moving the form elements into fieldsets during form building would break up that hierarchy. Therefore, we wait until the pre_render stage, where any changes we make affect presentation only and aren't reflected in $form_state->getValues().

Parameters

array $form

The form build array to alter.

Return Value

array

The form build array.

static array preRenderFlattenData(array $form)

Flattens the structure of form elements.

If a form element has #flatten = TRUE, then all of its children get moved to the same level as the element itself. So $form['to_be_flattened'][$key] becomes $form[$key], and $form['to_be_flattened'] gets unset.

Parameters

array $form

The form build array to alter.

Return Value

array

The form build array.

array calculateDependencies()

Calculates dependencies for the configured plugin.

Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.

Return Value

array

An array of dependencies grouped by type (config, content, module, theme). For example: @code array( 'config' => array('user.role.anonymous', 'user.role.authenticated'), 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'), 'module' => array('node', 'user'), 'theme' => array('seven'), ); @endcode

string getProvider()

Returns the plugin provider.

Return Value

string

protected array listLanguages(int $flags = LanguageInterface::STATE_ALL, array $current_values = NULL)

Makes an array of languages, optionally including special languages.

Parameters

int $flags

(optional) Flags for which languages to return (additive). Options:

  • \Drupal\Core\Language::STATE_ALL (default): All languages (configurable and default).
  • \Drupal\Core\Language::STATE_CONFIGURABLE: Configurable languages.
  • \Drupal\Core\Language::STATE_LOCKED: Locked languages.
  • \Drupal\Core\Language::STATE_SITE_DEFAULT: Add site default language; note that this is not included in STATE_ALL.
  • \Drupal\views\Plugin\views\PluginBase::INCLUDE_NEGOTIATED: Add negotiated language types.
  • \Drupal\views\Plugin\views\PluginBase::INCLUDE_ENTITY: Add entity row language types. Note that these are only supported for display options, not substituted in queries.
array $current_values

The currently-selected options in the list, if available.

Return Value

array

An array of language names, keyed by the language code. Negotiated and special languages have special codes that are substituted in queries by PluginBase::queryLanguageSubstitutions(). Only configurable languages and languages that are in $current_values are included in the list.

static array queryLanguageSubstitutions()

Returns substitutions for Views queries for languages.

This is needed so that the language options returned by PluginBase::listLanguages() are able to be used in queries. It is called by the Views module implementation of hook_views_query_substitutions() to get the language-related substitutions.

Return Value

array

An array in the format of hook_views_query_substitutions() that gives the query substitutions needed for the special language types.

protected RendererInterface getRenderer()

Returns the render API renderer.

Return Value

RendererInterface

adminLabel($short = FALSE)

Return a string representing this handler's name in the UI.

Parameters

$short

getField($field = NULL)

Shortcut to get a handler's raw field value.

This should be overridden for handlers with formulae or other non-standard fields. Because this takes an argument, fields overriding this can just call return parent::getField($formula)

Parameters

$field

ViewsRenderPipelineMarkup sanitizeValue($value, $type = NULL)

Sanitize the value for output.

Parameters

$value

The value being rendered.

$type

The type of sanitization needed. If not provided, \Drupal\Component\Utility\Html::escape() is used.

Return Value

ViewsRenderPipelineMarkup

Returns the safe value.

protected string caseTransform($string, $option)

Transform a string by a certain method.

Parameters

$string

The input you want to transform.

$option

How do you want to transform it, possible values:

  • upper: Uppercase the string.
  • lower: lowercase the string.
  • ucfirst: Make the first char uppercase.
  • ucwords: Make each word in the string uppercase.

Return Value

string

The transformed string.

protected ModuleHandlerInterface getModuleHandler()

Gets the module handler.

Return Value

ModuleHandlerInterface

setModuleHandler(ModuleHandlerInterface $module_handler)

Sets the module handler.

Parameters

ModuleHandlerInterface $module_handler

The module handler.

usesGroupBy()

Provides the handler some groupby.

buildGroupByForm($form, FormStateInterface $form_state)

Provide a form for aggregation settings.

Parameters

$form
FormStateInterface $form_state

submitGroupByForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form values prior to storage.

There is no need for this function to actually store the data.

Parameters

$form
FormStateInterface $form_state

hasExtraOptions()

If a handler has 'extra options' it will get a little settings widget and another form called extra_options.

defineExtraOptions($option)

Provide defaults for the handler.

Parameters

$option

buildExtraOptionsForm($form, FormStateInterface $form_state)

Provide a form for setting options.

Parameters

$form
FormStateInterface $form_state

validateExtraOptionsForm($form, FormStateInterface $form_state)

Validate the options form.

Parameters

$form
FormStateInterface $form_state

submitExtraOptionsForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form values prior to storage.

There is no need for this function to actually store the data.

Parameters

$form
FormStateInterface $form_state

canExpose()

Determine if a handler can be exposed.

defaultExposeOptions()

Set new exposed option defaults when exposed setting is flipped on.

exposedInfo()

Get information about the exposed form for the form renderer.

buildExposedForm($form, FormStateInterface $form_state)

Render our chunk of the exposed handler form when selecting.

Parameters

$form
FormStateInterface $form_state

validateExposed($form, FormStateInterface $form_state)

Validate the exposed handler form.

Parameters

$form
FormStateInterface $form_state

submitExposed($form, FormStateInterface $form_state)

Submit the exposed handler form.

Parameters

$form
FormStateInterface $form_state

buildExposeForm($form, FormStateInterface $form_state)

Form for exposed handler options.

Parameters

$form
FormStateInterface $form_state

validateExposeForm($form, FormStateInterface $form_state)

Validate the options form.

Parameters

$form
FormStateInterface $form_state

submitExposeForm($form, FormStateInterface $form_state)

Perform any necessary changes to the form exposes prior to storage.

There is no need for this function to actually store the data.

Parameters

$form
FormStateInterface $form_state

showExposeButton($form, FormStateInterface $form_state)

Shortcut to display the expose/hide button.

Parameters

$form
FormStateInterface $form_state

showExposeForm($form, FormStateInterface $form_state)

Shortcut to display the exposed options form.

Parameters

$form
FormStateInterface $form_state

bool access(AccountInterface $account)

Check whether given user has access to this handler.

Parameters

AccountInterface $account

The user account to check.

Return Value

bool

TRUE if the user has access to the handler, FALSE otherwise.

preQuery()

Run before the view is built.

This gives all the handlers some time to set up before any handler has been fully run.

postExecute($values)

Run after the view is executed, before the result is cached.

This gives all the handlers some time to modify values. This is primarily used so that handlers that pull up secondary data can put it in the $values so that the raw data can be used externally.

Parameters

$values

protected string placeholder()

Provides a unique placeholders for handlers.

Return Value

string

A placeholder which contains the table and the fieldname.

setRelationship()

Called just prior to query(), this lets a handler set up any relationship it needs.

ensureMyTable()

Ensure the main table for this handler is in the query. This is used a lot.

adminSummary()

Provide extra data to the administration form.

bool isExposed()

Determine if this item is 'exposed', meaning it provides form elements to let users modify the view.

Return Value

bool

isAGroup()

Returns TRUE if the exposed filter works like a grouped filter.

multipleExposedInput()

Define if the exposed input has to be submitted multiple times.

This is TRUE when exposed filters grouped are using checkboxes as widgets.

acceptExposedInput($input)

Take input from exposed handlers and assign to this handler, if necessary.

Parameters

$input

storeExposedInput($input, $status)

If set to remember exposed input in the session, store it there.

Parameters

$input
$status

getJoin()

Get the join object that should be used for this handler.

This method isn't used a great deal, but it's very handy for easily getting the join if it is necessary to make some changes to it, such as adding an 'extra'.

broken()

Determines if the handler is considered 'broken', meaning it's a placeholder used when a handler can't be found.

string getDateFormat(string $format)

Creates cross-database SQL date formatting.

Parameters

string $format

A format string for the result, like 'Y-m-d H:i:s'.

Return Value

string

An appropriate SQL string for the DB type and field type.

string getDateField()

Creates cross-database SQL dates.

Return Value

string

An appropriate SQL string for the db type and field type.

protected ViewsData getViewsData()

Gets views data service.

Return Value

ViewsData

setViewsData(ViewsData $views_data)

{@inheritdoc}

Parameters

ViewsData $views_data

static JoinPluginBase getTableJoin(string $table, string $base_table)

Fetches a handler to join one table to a primary table from the data cache.

Parameters

string $table

The table to join from.

string $base_table

The table to join to.

Return Value

JoinPluginBase

string getEntityType()

Determines the entity type used by this handler.

If this handler uses a relationship, the base class of the relationship is taken into account.

Return Value

string

The machine name of the entity type.

static object breakString(string $str, bool $force_int = FALSE)

Breaks x,y,z and x+y+z into an array.

Parameters

string $str

The string to split.

bool $force_int

Enforce a numeric check.

Return Value

object

A stdClass object containing value and operator properties.

displayExposedForm($form, FormStateInterface $form_state)

Displays the Expose form.

Parameters

$form
FormStateInterface $form_state

submitTemporaryForm($form, FormStateInterface $form_state)

A submit handler that is used for storing temporary items when using multi-step changes, such as ajax requests.

Parameters

$form
FormStateInterface $form_state

array submitFormCalculateOptions(array $options, array $form_state_options)

Calculates options stored on the handler.

Parameters

array $options

The options stored in the handler

array $form_state_options

The newly submitted form state options.

Return Value

array

The new options

protected allowAdvancedRender()

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 addAdditionalFields($fields = NULL)

Add 'additional' fields to the query.

Parameters

$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

clickSort(string $order)

Adds an ORDER BY clause to the query for click sort columns.

Parameters

string $order

Either ASC or DESC

bool clickSortable()

Determines if this field is click sortable.

Return Value

bool

The value of 'click sortable' from the plugin definition, this defaults to TRUE if not set.

label()

Gets this field's label.

elementType(bool $none_supported = FALSE, bool $default_empty = FALSE, bool $inline = FALSE)

Returns an HTML element based upon the field's element type.

Parameters

bool $none_supported

Whether or not this HTML element is supported.

bool $default_empty

Whether or not this HTML element is empty by default.

bool $inline

Whether or not this HTML element is inline.

elementLabelType(bool $none_supported = FALSE, bool $default_empty = FALSE)

Returns an HTML element for the label based upon the field's element type.

Parameters

bool $none_supported

Whether or not this HTML element is supported.

bool $default_empty

Whether or not this HTML element is empty by default.

elementWrapperType(bool $none_supported = FALSE, bool $default_empty = FALSE)

Returns an HTML element for the wrapper based upon the field's element type.

Parameters

bool $none_supported

Whether or not this HTML element is supported.

bool $default_empty

Whether or not this HTML element is empty by default.

getElements()

Provides a list of elements valid for field HTML.

This function can be overridden by fields that want more or fewer elements available, though this seems like it would be an incredibly rare occurrence.

elementClasses(bool $row_index = NULL)

Returns the class of the field.

Parameters

bool $row_index

The index of current row.

tokenizeValue(string $value, bool $row_index = NULL)

Replaces a value with tokens from the last field.

This function actually figures out which field was last and uses its tokens so they will all be available.

Parameters

string $value

The raw string.

bool $row_index

The index of current row.

elementLabelClasses(bool $row_index = NULL)

Returns the class of the field's label.

Parameters

bool $row_index

The index of current row.

elementWrapperClasses(bool $row_index = NULL)

Returns the class of the field's wrapper.

Parameters

bool $row_index

The index of current row.

EntityInterface|null getEntity(ResultRow $values)

Gets the entity matching the current row and relationship.

Parameters

ResultRow $values

An object containing all retrieved values.

Return Value

EntityInterface|null

Returns the entity matching the values or NULL if there is no matching entity.

getValue(ResultRow $row, string $field = NULL)

Gets the value that's supposed to be rendered.

This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters

ResultRow $row
string $field

Optional name of the field where the value is stored.

bool useStringGroupBy()

Determines if this field will be available as an option to group the result by in the style settings.

Return Value

bool

TRUE if this field handler is groupable, otherwise FALSE.

protected array getPreviousFieldLabels()

Returns all field labels of fields before this field.

Return Value

array

An array of field labels keyed by their field IDs.

preRender(ResultRow[] $values)

Runs before any fields are rendered.

This gives the handlers some time to set up before any handler has been rendered.

Parameters

ResultRow[] $values

An array of all ResultRow objects returned from the query.

string|MarkupInterface render(ResultRow $values)

Renders the field.

Parameters

ResultRow $values

The values retrieved from a single row of a view's query result.

Return Value

string|MarkupInterface

The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

string[] postRender(ResultRow $row, $output)

Runs after every field has been rendered.

This is meant to be used mainly to deal with field handlers whose output cannot be cached at row level but can be cached at display level. The typical example is the row counter. For completely uncacheable field output placeholders should be used.

Parameters

ResultRow $row

An array of all ResultRow objects returned from the query.

$output

The field rendered output.

Return Value

string[]

An associative array of post-render token values keyed by placeholder.

string|MarkupInterface advancedRender(ResultRow $values)

Renders a field using advanced settings.

This renders a field normally, then decides if render-as-link and text-replacement rendering is necessary.

Parameters

ResultRow $values

The values retrieved from a single row of a view's query result.

Return Value

string|MarkupInterface

The advanced rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

bool isValueEmpty($value, bool $empty_zero, bool $no_skip_empty = TRUE)

Checks if a field value is empty.

Parameters

$value

The field value.

bool $empty_zero

Whether or not this field is configured to consider 0 as empty.

bool $no_skip_empty

Whether or not to use empty() to check the value.

Return Value

bool

TRUE if the value is considered empty, FALSE otherwise.

string|MarkupInterface renderText(array $alter)

Performs an advanced text render for the item.

This is separated out as some fields may render lists, and this allows each item to be handled individually.

Parameters

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.

Return Value

string|MarkupInterface

The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

protected renderAltered($alter, $tokens)

Render this field as user-defined altered text.

Parameters

$alter
$tokens

protected string renderTrimText(array $alter, string $value)

Trims the field down to the specified length.

Parameters

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.
string $value

The string which should be trimmed.

Return Value

string

The rendered trimmed string.

Render this field as a link, with the info from a fieldset set by the user.

Parameters

$alter
$text
$tokens

array getRenderTokens(mixed $item)

Gets the 'render' tokens to use for advanced rendering.

This runs through all of the fields and arguments that are available and gets their values. This will then be used in one giant str_replace().

Parameters

mixed $item

The item to render.

Return Value

array

An array of available tokens

protected string getFieldTokenPlaceholder()

Returns a token placeholder for the current field.

Return Value

string

A token placeholder.

protected An getTokenValuesRecursive(array $array, array $parent_keys = [])

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' );

Parameters

array $array

An array of values.

array $parent_keys

An array of parent keys. This will represent the array depth.

Return Value

An

array of available tokens, with nested keys representative of the array structure.

protected addSelfTokens($tokens, $item)

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 {{ tokensubtoken }} where token is the field ID and subtoken is the field. If the field ID is terms, then the tokens might be {{ termstid }} and {{ terms__name }}.

Parameters

$tokens
$item

protected documentSelfTokens($tokens)

Document any special tokens this field might use for itself.

Parameters

$tokens

See also

addSelfTokens()

string|MarkupInterface theme(ResultRow $values)

Renders row values using $this->themeFunctions() as #theme.

Parameters

ResultRow $values

Holds single row of a view's result set.

Return Value

string|MarkupInterface

Returns rendered output of the given theme implementation. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

static string trimText(array $alter, string $value)

Trims the field down to the specified length.

Parameters

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.
string $value

The string which should be trimmed.

Return Value

string

The trimmed string.

protected LinkGeneratorInterface linkGenerator()

Gets the link generator.

Return Value

LinkGeneratorInterface

viewsForm(array $form, FormStateInterface $form_state)

Form constructor for the media library select form.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

static AjaxResponse updateWidget(array $form, FormStateInterface $form_state, Request $request)

Submit handler for the media library select form.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

Request $request

The current request.

Return Value

AjaxResponse

A command to send the selection to the current field widget.

viewsFormValidate(array $form, FormStateInterface $form_state)

{@inheritdoc}

Parameters

array $form
FormStateInterface $form_state