abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouterInterface, DisplayMenuInterface (View source)

The base display plugin for path/callbacks. This is used for pages and feeds.

Traits

Provides a trait for calculating the dependencies of a plugin.

Provides a trait for managing an object's dependencies.

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.

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  DisplayPluginBase
DisplayPluginBase $displayHandler

The display object this plugin is for.

from  PluginBase
array $definition

Plugins's definition.

from  PluginBase
protected $usesOptions {@inheritdoc} from  DisplayPluginBase
protected RendererInterface $renderer

Stores the render API renderer.

from  PluginBase
protected array $dependencies

The object's dependencies.

from  DependencyTrait
ViewsHandlerInterface[] $handlers

An array of instantiated handlers used in this display.

from  DisplayPluginBase
protected ViewsPluginInterface[] $plugins

An array of instantiated plugins used in this display.

from  DisplayPluginBase
protected DisplayExtenderPluginBase[] $extenders

Stores all available display extenders.

from  DisplayPluginBase
string $output

Stores the rendered output of the display.

from  DisplayPluginBase
protected bool $usesAJAX

Whether the display allows the use of AJAX or not.

from  DisplayPluginBase
protected bool $usesPager

Whether the display allows the use of a pager or not.

from  DisplayPluginBase
protected bool $usesMore

Whether the display allows the use of a 'more' link or not.

from  DisplayPluginBase
protected bool $usesAttachments

Whether the display allows attachments.

from  DisplayPluginBase
protected bool $usesAreas

Whether the display allows area plugins.

from  DisplayPluginBase
static protected array $unpackOptions

Static cache for unpackOptions, but not if we are in the UI.

from  DisplayPluginBase
array $display

The display information coming directly from the view entity.

from  DisplayPluginBase
protected RouteProviderInterface $routeProvider

The route provider.

protected StateInterface $state

The state key value store.

Methods

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state)

Constructs a PathPluginBase 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()

Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions().

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)

Provide a form to edit options for this plugin.

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)

Handle any special handling on the validate form.

query()

Add anything to the query that we might need to.

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.

$this
addDependency(string $type, string $name)

Adds a dependency.

addDependencies(array $dependencies)

Adds multiple dependencies.

array
getPluginDependencies(PluginInspectionInterface $instance)

Calculates and returns dependencies of a specific plugin instance.

calculatePluginDependencies(PluginInspectionInterface $instance)

Calculates and adds dependencies of a specific plugin instance.

moduleHandler()

Wraps the module handler.

themeHandler()

Wraps the theme handler.

initDisplay(ViewExecutable $view, array $display, array $options = NULL)

Initializes the display plugin.

isDefaultDisplay()

Determines if this display is the 'default' display.

usesExposed()

Determines if this display uses exposed filters.

displaysExposed()

Determines if this display should display the exposed filters widgets.

bool
usesAJAX()

Whether the display allows the use of AJAX or not.

bool
ajaxEnabled()

Whether the display is actually using AJAX or not.

bool
isEnabled()

Whether the display is enabled.

bool
usesPager()

Whether the display allows the use of a pager or not.

bool
isPagerEnabled()

Whether the display is using a pager or not.

bool
usesMore()

Whether the display allows the use of a 'more' link or not.

bool
isMoreEnabled()

Whether the display is using the 'more' link or not.

useGroupBy()

Does the display have groupby enabled?

useMoreAlways()

Should the enabled display more link be shown when no more items?

useMoreText()

Does the display have custom link text?

bool
acceptAttachments()

Determines whether this display can use attachments.

bool
usesAttachments()

Returns whether the display can use attachments.

bool
usesAreas()

Returns whether the display can use areas.

attachTo(ViewExecutable $view, string $display_id, array $build)

Allows displays to attach to other views.

defaultableSections($section = NULL)

Lists the 'defaultable' sections and what items each section contains.

hasPath()

Checks to see if the display has a 'path' field.

usesLinkDisplay()

Checks to see if the display has some need to link to another display.

usesExposedFormInBlock()

Checks to see if the display can put the exposed form in a block.

getAttachedDisplays()

Find out all displays which are attached to this display.

getLinkDisplay()

Returns the ID of the display to use when making links.

getPath()

Returns the base path to use for this display.

getRoutedDisplay()

Points to the display which can be linked by this display.

Url|null
getUrl()

Returns a URL to $this display or its configured linked display.

true
isDefaulted($option)

Determines if an option is set to use the default or current display.

getOption($option)

Gets an option, from this display or the default display.

bool
usesFields()

Determines if the display's style uses fields.

getPlugin(string $type)

Get the instance of a plugin, for example style or row.

getHandler($type, $id)

Get the handler object for a single handler.

getHandlers($type)

Get a full array of handlers for $type. This caches them.

getAllHandlers(bool $only_overrides = FALSE)

Gets all the handlers used by the display.

getAllPlugins(bool $only_overrides = FALSE)

Gets all the plugins used by the display.

array
getFieldLabels(bool $groupable_only = FALSE)

Retrieves a list of fields for the current display.

setOption($option, $value)

Sets an option, on this display or the default display.

overrideOption($option, $value)

Set an option and force it to be an override.

optionLink($text, $section, $class = '', $title = '')

Returns a link to a section of a form.

getArgumentsTokens()

Returns to tokens for arguments.

optionsSummary($categories, $options)

Provides the default summary for options in the views UI.

optionsOverride($form, FormStateInterface $form_state)

If override/revert was clicked, perform the proper toggle.

setOverride(string $section, bool $new_state = NULL)

Flip the override setting for the given section.

renderFilters()

Does nothing (obsolete function).

renderPager()

Checks to see if the display plugins support pager rendering.

renderMoreLink()

Renders the 'more' link.

Url
getMoreUrl()

Get the more URL for this view.

render()

Renders this display.

applyDisplayCacheabilityMetadata(array $element)

Applies the cacheability of the current display to the given render array.

array
elementPreRender(array $element)

pre_render callback for view display rendering.

array
renderArea(string $area, bool $empty = FALSE)

Renders one of the available areas.

access(AccountInterface $account = NULL)

Determines if the user has access to this display of the view.

preExecute()

Sets up any variables on the view prior to execution.

calculateCacheMetadata()

Calculates the display's cache metadata by inspecting each handler/plugin.

getCacheMetadata()

Gets the cache metadata.

execute()

Executes the view and returns data in the format required.

array
buildRenderable(array $args = [], bool $cache = TRUE)

Builds a renderable array of the view.

static array
buildBasicRenderable(string $view_id, string $display_id, array $args = [])

Builds a basic render array which can be properly render cached.

preview()

Renders the display for the purposes of a live preview.

string
getType()

Returns the display type that this display requires.

newDisplay()

Reacts on adding a display.

bool
isIdentifierUnique(string $id, string $identifier)

Checks if the provided identifier is unique.

bool
outputIsEmpty()

Is the output of the view empty.

getSpecialBlocks()

Provides the block system with any exposed widget blocks for this display.

array|null
viewExposedFormBlocks()

Renders the exposed form as block.

array
getArgumentText()

Provides help text for the arguments.

array
getPagerText()

Provides help text for pagers.

mergeDefaults()

Merges default values for all plugin types.

remove()

Reacts on deleting a display.

mergePlugin(string $type)

Merges plugins default values.

mergeHandler(string $type)

Merges handlers default values.

getExtenders()

Gets the display extenders.

array
buildRenderingLanguageOptions()

Returns the available rendering strategies for language-aware entities.

bool
isBaseTableTranslatable()

Returns whether the base table is of a translatable entity type.

bool
isDefaultTabPath()

Determines if this display's path is a default tab.

Route
getRoute(string $view_id, string $display_id)

Generates a route entry for a given view and display.

collectRoutes(RouteCollection $collection)

Adds the route entry of a view to the collection.

bool
overrideApplies(string $view_path, Route $view_route, Route $route)

Determines whether the view overrides the given route.

bool
overrideAppliesPathAndMethod(string $view_path, Route $view_route, Route $route)

Determines whether an override for the path and method should happen.

array
alterRoutes(RouteCollection $collection)

Alters a collection of routes and replaces definitions to the view.

array
getMenuLinks()

Gets menu links, if this display provides some.

array
validatePath(string $path)

Validates the path of the display.

Url
getUrlInfo()

Generates a URL to this display.

string
getRouteName()

Returns the route name for the display.

string[]
getAlteredRouteNames()

Returns the list of routes overridden by Views.

Details

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, RouteProviderInterface $route_provider, StateInterface $state)

Constructs a PathPluginBase 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.

RouteProviderInterface $route_provider

The route provider.

StateInterface $state

The state key value store.

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()

Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions().

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)

Provide a form to edit options for this plugin.

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)

Handle any special handling on the validate form.

Parameters

$form
FormStateInterface $form_state

query()

Add anything to the query that we might need to.

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

protected $this addDependency(string $type, string $name)

Adds a dependency.

Parameters

string $type

Type of dependency being added: 'module', 'theme', 'config', 'content'.

string $name

If $type is 'module' or 'theme', the name of the module or theme. If $type is 'config' or 'content', the result of EntityInterface::getConfigDependencyName().

Return Value

$this

See also

EntityInterface::getConfigDependencyName

protected addDependencies(array $dependencies)

Adds multiple dependencies.

Parameters

array $dependencies

An array of dependencies keyed by the type of dependency. One example: @code array( 'module' => array( 'node', 'field', 'image', ), ); @endcode

See also

DependencyTrait::addDependency

protected array getPluginDependencies(PluginInspectionInterface $instance)

Calculates and returns dependencies of a specific plugin instance.

Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.

Parameters

PluginInspectionInterface $instance

The plugin instance.

Return Value

array

An array of dependencies keyed by the type of dependency.

protected calculatePluginDependencies(PluginInspectionInterface $instance)

Calculates and adds dependencies of a specific plugin instance.

Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.

Parameters

PluginInspectionInterface $instance

The plugin instance.

protected ModuleHandlerInterface moduleHandler()

Wraps the module handler.

Return Value

ModuleHandlerInterface

The module handler.

protected ThemeHandlerInterface themeHandler()

Wraps the theme handler.

Return Value

ThemeHandlerInterface

The theme handler.

initDisplay(ViewExecutable $view, array $display, array $options = NULL)

Initializes the display plugin.

Parameters

ViewExecutable $view

The views executable.

array $display

The display that will be populated and attached to the view.

array $options

(optional) The options for the display plugin. Defaults to NULL.

isDefaultDisplay()

Determines if this display is the 'default' display.

'Default' display contains fallback settings.

usesExposed()

Determines if this display uses exposed filters.

displaysExposed()

Determines if this display should display the exposed filters widgets.

Regardless of what this function returns, exposed filters will not be used nor displayed unless usesExposed() returns TRUE.

bool usesAJAX()

Whether the display allows the use of AJAX or not.

Return Value

bool

bool ajaxEnabled()

Whether the display is actually using AJAX or not.

Return Value

bool

bool isEnabled()

Whether the display is enabled.

Return Value

bool

Returns TRUE if the display is marked as enabled, else FALSE.

bool usesPager()

Whether the display allows the use of a pager or not.

Return Value

bool

bool isPagerEnabled()

Whether the display is using a pager or not.

Return Value

bool

bool usesMore()

Whether the display allows the use of a 'more' link or not.

Return Value

bool

bool isMoreEnabled()

Whether the display is using the 'more' link or not.

Return Value

bool

useGroupBy()

Does the display have groupby enabled?

useMoreAlways()

Should the enabled display more link be shown when no more items?

useMoreText()

Does the display have custom link text?

bool acceptAttachments()

Determines whether this display can use attachments.

Return Value

bool

bool usesAttachments()

Returns whether the display can use attachments.

Return Value

bool

bool usesAreas()

Returns whether the display can use areas.

Return Value

bool

TRUE if the display can use areas, or FALSE otherwise.

attachTo(ViewExecutable $view, string $display_id, array $build)

Allows displays to attach to other views.

Parameters

ViewExecutable $view

The views executable.

string $display_id

The display to attach to.

array $build

The parent view render array.

defaultableSections($section = NULL)

Lists the 'defaultable' sections and what items each section contains.

Parameters

$section

hasPath()

Checks to see if the display has a 'path' field.

This is a pure function and not just a setting on the definition because some displays (such as a panel pane) may have a path based upon configuration.

By default, displays do not have a path.

usesLinkDisplay()

Checks to see if the display has some need to link to another display.

For the most part, displays without a path will use a link display. However, sometimes displays that have a path might also need to link to another display. This is true for feeds.

usesExposedFormInBlock()

Checks to see if the display can put the exposed form in a block.

By default, displays that do not have a path cannot disconnect the exposed form and put it in a block, because the form has no place to go and Views really wants the forms to go to a specific page.

getAttachedDisplays()

Find out all displays which are attached to this display.

The method is just using the pure storage object to avoid loading of the sub displays which would kill lazy loading.

getLinkDisplay()

Returns the ID of the display to use when making links.

getPath()

Returns the base path to use for this display.

This can be overridden for displays that do strange things with the path.

DisplayRouterInterface|null getRoutedDisplay()

Points to the display which can be linked by this display.

If the display has route information, the display itself is returned. Otherwise, the configured linked display is returned. For example, if a block display links to a page display, the page display will be returned in both cases.

Return Value

DisplayRouterInterface|null

Url|null getUrl()

Returns a URL to $this display or its configured linked display.

Return Value

Url|null

true isDefaulted($option)

Determines if an option is set to use the default or current display.

Parameters

$option

Return Value

true

for the default display.

getOption($option)

Gets an option, from this display or the default display.

Parameters

$option

bool usesFields()

Determines if the display's style uses fields.

Return Value

bool

ViewsPluginInterface getPlugin(string $type)

Get the instance of a plugin, for example style or row.

Parameters

string $type

The type of the plugin.

Return Value

ViewsPluginInterface

getHandler($type, $id)

Get the handler object for a single handler.

Parameters

$type
$id

ViewsHandlerInterface[] getHandlers($type)

Get a full array of handlers for $type. This caches them.

Parameters

$type

Return Value

ViewsHandlerInterface[]

protected ViewsHandlerInterface[] getAllHandlers(bool $only_overrides = FALSE)

Gets all the handlers used by the display.

Parameters

bool $only_overrides

Whether to include only overridden handlers.

Return Value

ViewsHandlerInterface[]

protected ViewsPluginInterface[] getAllPlugins(bool $only_overrides = FALSE)

Gets all the plugins used by the display.

Parameters

bool $only_overrides

Whether to include only overridden plugins.

Return Value

ViewsPluginInterface[]

array getFieldLabels(bool $groupable_only = FALSE)

Retrieves a list of fields for the current display.

This also takes into account any associated relationships, if they exist.

Parameters

bool $groupable_only

(optional) TRUE to only return an array of field labels from handlers that support the useStringGroupBy method, defaults to FALSE.

Return Value

array

An array of applicable field options, keyed by ID.

setOption($option, $value)

Sets an option, on this display or the default display.

Parameters

$option
$value

overrideOption($option, $value)

Set an option and force it to be an override.

Parameters

$option
$value

Returns a link to a section of a form.

Because forms may be split up into sections, this provides an easy URL to exactly the right section. Don't override this.

Parameters

$text
$section
$class
$title

getArgumentsTokens()

Returns to tokens for arguments.

This function is similar to views_handler_field::getRenderTokens() but without fields tokens.

optionsSummary($categories, $options)

Provides the default summary for options in the views UI.

This output is returned as an array.

Parameters

$categories
$options

optionsOverride($form, FormStateInterface $form_state)

If override/revert was clicked, perform the proper toggle.

Parameters

$form
FormStateInterface $form_state

setOverride(string $section, bool $new_state = NULL)

Flip the override setting for the given section.

Parameters

string $section

Which option should be marked as overridden, for example "filters".

bool $new_state

Select the new state of the option:

  • TRUE: Revert new state option to default.
  • FALSE: Mark it as overridden.

renderFilters()

Does nothing (obsolete function).

renderPager()

Checks to see if the display plugins support pager rendering.

Renders the 'more' link.

protected Url getMoreUrl()

Get the more URL for this view.

Uses the custom URL if there is one, otherwise the display path.

Return Value

Url

The more link as Url object.

render()

Renders this display.

protected applyDisplayCacheabilityMetadata(array $element)

Applies the cacheability of the current display to the given render array.

Parameters

array $element

The render array with updated cacheability metadata.

array elementPreRender(array $element)

pre_render callback for view display rendering.

Parameters

array $element

The element to #pre_render

Return Value

array

The processed element.

array renderArea(string $area, bool $empty = FALSE)

Renders one of the available areas.

Parameters

string $area

Identifier of the specific area to render.

bool $empty

(optional) Indicator whether or not the view result is empty. Defaults to FALSE

Return Value

array

A render array for the given area.

access(AccountInterface $account = NULL)

Determines if the user has access to this display of the view.

Parameters

AccountInterface $account

preExecute()

Sets up any variables on the view prior to execution.

These are separated from execute because they are extremely common and unlikely to be overridden on an individual display.

CacheableMetadata calculateCacheMetadata()

Calculates the display's cache metadata by inspecting each handler/plugin.

Return Value

CacheableMetadata

The cache metadata.

CacheableMetadata getCacheMetadata()

Gets the cache metadata.

Return Value

CacheableMetadata

The cache metadata.

execute()

Executes the view and returns data in the format required.

The base class cannot be executed.

array buildRenderable(array $args = [], bool $cache = TRUE)

Builds a renderable array of the view.

Note: This does not yet contain the executed view, but just the loaded view executable.

Parameters

array $args

(optional) Arguments of the view.

bool $cache

(optional) Specify FALSE in order to opt out of render caching.

Return Value

array

The render array of a view.

static array buildBasicRenderable(string $view_id, string $display_id, array $args = [])

Builds a basic render array which can be properly render cached.

In order to be rendered cached, it includes cache keys as well as the data required to load the view on cache misses.

Parameters

string $view_id

The view ID.

string $display_id

The display ID.

array $args

(optional) The view arguments.

Return Value

array

The view render array.

preview()

Renders the display for the purposes of a live preview.

Also might be used for some other AJAXy reason.

string getType()

Returns the display type that this display requires.

This can be used for filtering views plugins. E.g. if a plugin category of 'foo' is specified, only plugins with no 'types' declared or 'types' containing 'foo'. If you have a type of bar, this plugin will not be used. This is applicable for style, row, access, cache, and exposed_form plugins.

Return Value

string

The required display type. Defaults to 'normal'.

newDisplay()

Reacts on adding a display.

bool isIdentifierUnique(string $id, string $identifier)

Checks if the provided identifier is unique.

Parameters

string $id

The id of the handler which is checked.

string $identifier

The actual get identifier configured in the exposed settings.

Return Value

bool

Returns whether the identifier is unique on all handlers.

bool outputIsEmpty()

Is the output of the view empty.

If a view has no result and neither the empty, nor the footer nor the header does show anything return FALSE.

Return Value

bool

Returns TRUE if the output is empty, else FALSE.

getSpecialBlocks()

Provides the block system with any exposed widget blocks for this display.

array|null viewExposedFormBlocks()

Renders the exposed form as block.

Return Value

array|null

The renderable exposed form as array or NULL otherwise.

array getArgumentText()

Provides help text for the arguments.

Return Value

array

Returns an array which contains text for the argument fieldset:

  • filter value present: The title of the fieldset in the argument where you can configure what should be done with a given argument.
  • filter value not present: The title of the fieldset in the argument where you can configure what should be done if the argument does not exist.
  • description: A description about how arguments are passed to the display. For example blocks can't get arguments from url.

array getPagerText()

Provides help text for pagers.

Return Value

array

Returns an array which contains text for the items_per_page form element:

  • items per page title: The title text for the items_per_page form element.
  • items per page description: The description text for the items_per_page form element.

mergeDefaults()

Merges default values for all plugin types.

remove()

Reacts on deleting a display.

protected mergePlugin(string $type)

Merges plugins default values.

Parameters

string $type

The name of the plugin type option.

protected mergeHandler(string $type)

Merges handlers default values.

Parameters

string $type

The name of the handler type option.

DisplayExtenderPluginBase[] getExtenders()

Gets the display extenders.

Return Value

DisplayExtenderPluginBase[]

protected array buildRenderingLanguageOptions()

Returns the available rendering strategies for language-aware entities.

Return Value

array

An array of available entity row renderers keyed by renderer identifiers.

protected bool isBaseTableTranslatable()

Returns whether the base table is of a translatable entity type.

Return Value

bool

TRUE if the base table is of a translatable entity type, FALSE otherwise.

protected bool isDefaultTabPath()

Determines if this display's path is a default tab.

Return Value

bool

TRUE if the display path is for a default tab, FALSE otherwise.

protected Route getRoute(string $view_id, string $display_id)

Generates a route entry for a given view and display.

Parameters

string $view_id

The ID of the view.

string $display_id

The current display ID.

Return Value

Route

The route for the view.

collectRoutes(RouteCollection $collection)

Adds the route entry of a view to the collection.

Parameters

RouteCollection $collection

A collection of routes that should be registered for this resource.

protected bool overrideApplies(string $view_path, Route $view_route, Route $route)

Determines whether the view overrides the given route.

Parameters

string $view_path

The path of the view.

Route $view_route

The route of the view.

Route $route

The route itself.

Return Value

bool

TRUE, when the view should override the given route.

protected bool overrideAppliesPathAndMethod(string $view_path, Route $view_route, Route $route)

Determines whether an override for the path and method should happen.

Parameters

string $view_path

The path of the view.

Route $view_route

The route of the view.

Route $route

The route itself.

Return Value

bool

TRUE, when the view should override the given route.

array alterRoutes(RouteCollection $collection)

Alters a collection of routes and replaces definitions to the view.

Most of the collections won't have the needed route, so by the return value the method can specify to break the search.

Parameters

RouteCollection $collection

The route collection.

Return Value

array

Returns a list of "$view_id.$display_id" elements which got overridden.

Gets menu links, if this display provides some.

Return Value

array

The menu links registers for this display.

protected array validatePath(string $path)

Validates the path of the display.

Parameters

string $path

The path to validate.

Return Value

array

A list of error strings.

Url getUrlInfo()

Generates a URL to this display.

Return Value

Url

A URL object for the display.

string getRouteName()

Returns the route name for the display.

The default route name for a display is views.$view_id.$display_id. Some displays may override existing routes; in these cases, the route that is overridden is returned instead.

Return Value

string

The name of the route

string[] getAlteredRouteNames()

Returns the list of routes overridden by Views.

Return Value

string[]

An array of overridden route names. The keys are in the form view_id.display_id and the values are the route names.