interface DisplayPluginInterface (View source)

Provides an interface for Views display plugins.

Methods

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

Initializes the display plugin.

destroy()

Destroys the display's components and the display itself.

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.

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.

buildOptionsForm($form, FormStateInterface $form_state)

Provides the default form for setting options.

validateOptionsForm($form, FormStateInterface $form_state)

Validates the options form.

submitOptionsForm($form, FormStateInterface $form_state)

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

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.

query()

Injects anything into the query that the display handler needs.

renderFilters()

Does nothing (obsolete function).

renderPager()

Checks to see if the display plugins support pager rendering.

renderMoreLink()

Renders the 'more' link.

render()

Renders this display.

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.

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

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

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

Builds a renderable array of the view.

preview()

Renders the display for the purposes of a live preview.

string
getType()

Returns the display type that this display requires.

Empty
validate()

Make sure the display and all associated handlers are valid.

newDisplay()

Reacts on adding a display.

remove()

Reacts on deleting 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.

getExtenders()

Gets the display extenders.

Details

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.

destroy()

Destroys the display's components and the display itself.

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[]

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

buildOptionsForm($form, FormStateInterface $form_state)

Provides the default form for setting options.

Parameters

$form
FormStateInterface $form_state

validateOptionsForm($form, FormStateInterface $form_state)

Validates the options form.

Parameters

$form
FormStateInterface $form_state

submitOptionsForm($form, FormStateInterface $form_state)

Performs 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

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.

query()

Injects anything into the query that the display handler needs.

renderFilters()

Does nothing (obsolete function).

This function no longer seems to be used.

renderPager()

Checks to see if the display plugins support pager rendering.

Renders the 'more' link.

render()

Renders this display.

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.

See also

\Drupal\views\Plugin\views\display\self::render()

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.

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.

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.

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'.

See also

Views::fetchPluginNames

Empty validate()

Make sure the display and all associated handlers are valid.

Return Value

Empty

array if the display is valid; an array of error strings if it is not.

newDisplay()

Reacts on adding a display.

See also

\Drupal\views\Entity\View::newDisplay()

remove()

Reacts on deleting 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.

DisplayExtenderPluginBase[] getExtenders()

Gets the display extenders.

Return Value

DisplayExtenderPluginBase[]