class Views (View source)

Static service container wrapper for views.

Properties

static protected TranslationInterface $translationManager

The translation manager.

static protected array $handlerTypes

A static cache for handler types data.

static protected array $plugins

A list of all available views plugin types.

Methods

static ViewsData
viewsData()

Returns the views data service.

static ViewsDataHelper
viewsDataHelper()

Returns the views data helper service.

executableFactory()

Returns the view executable factory service.

static Analyzer
analyzer()

Returns the view analyzer.

pluginManager(string $type)

Returns the plugin manager for a certain views plugin type.

handlerManager($type)

Returns the plugin manager for a certain views handler type.

static ViewExecutable|null
getView(string $id)

Loads a view from configuration and returns its executable object.

static A
fetchPluginNames(string $type, string $key = NULL, array $base = [])

Fetches a list of all base tables available.

static array
getPluginDefinitions()

Gets all the views plugin definitions.

static 
getEnabledDisplayExtenders()

Gets enabled display extenders.

static array
getApplicableViews(string $type)

Return a list of all view IDs and display IDs that have a particular setting in their display's plugin settings.

static View[]
getAllViews()

Returns an array of all views as fully loaded $view objects.

static View[]
getEnabledViews()

Returns an array of all enabled views.

static View[]
getDisabledViews()

Returns an array of all disabled views.

static array
getViewsAsOptions(bool $views_only = FALSE, string $filter = 'all', mixed $exclude_view = NULL, bool $optgroup = FALSE, bool $sort = FALSE)

Returns an array of view as options array, that can be used by select, checkboxes and radios as #options.

static array
pluginList()

Returns a list of plugins and metadata about them.

static array
getHandlerTypes()

Provide a list of views handler types used in a view, with some information about them.

static array
getPluginTypes(string $type = NULL)

Returns a list of plugin types.

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

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

Details

static ViewsData viewsData()

Returns the views data service.

Return Value

ViewsData

Returns a views data cache object.

static ViewsDataHelper viewsDataHelper()

Returns the views data helper service.

Return Value

ViewsDataHelper

Returns a views data helper object.

static ViewExecutableFactory executableFactory()

Returns the view executable factory service.

Return Value

ViewExecutableFactory

Returns a views executable factory.

static Analyzer analyzer()

Returns the view analyzer.

Return Value

Analyzer

Returns a view analyzer object.

static ViewsPluginManager pluginManager(string $type)

Returns the plugin manager for a certain views plugin type.

Parameters

string $type

The plugin type, for example filter.

Return Value

ViewsPluginManager

static ViewsHandlerManager handlerManager($type)

Returns the plugin manager for a certain views handler type.

Parameters

$type

Return Value

ViewsHandlerManager

static ViewExecutable|null getView(string $id)

Loads a view from configuration and returns its executable object.

Parameters

string $id

The view ID to load.

Return Value

ViewExecutable|null

A view executable instance or NULL if the view does not exist.

static A fetchPluginNames(string $type, string $key = NULL, array $base = [])

Fetches a list of all base tables available.

Parameters

string $type

Either 'display', 'style' or 'row'.

string $key

For style plugins, this is an optional type to restrict to. May be 'normal', 'summary', 'feed' or others based on the needs of the display.

array $base

An array of possible base tables.

Return Value

A

keyed array of in the form of 'base_table' => 'Description'.

static array getPluginDefinitions()

Gets all the views plugin definitions.

Return Value

array

An array of plugin definitions for all types.

static getEnabledDisplayExtenders()

Gets enabled display extenders.

static array getApplicableViews(string $type)

Return a list of all view IDs and display IDs that have a particular setting in their display's plugin settings.

Parameters

string $type

A flag from the display plugin definitions (e.g, 'uses_menu_links').

Return Value

array

A list of arrays containing the $view_id and $display_id.

static View[] getAllViews()

Returns an array of all views as fully loaded $view objects.

Return Value

View[]

An array of loaded view entities.

static View[] getEnabledViews()

Returns an array of all enabled views.

Return Value

View[]

An array of loaded enabled view entities.

static View[] getDisabledViews()

Returns an array of all disabled views.

Return Value

View[]

An array of loaded disabled view entities.

static array getViewsAsOptions(bool $views_only = FALSE, string $filter = 'all', mixed $exclude_view = NULL, bool $optgroup = FALSE, bool $sort = FALSE)

Returns an array of view as options array, that can be used by select, checkboxes and radios as #options.

Parameters

bool $views_only

If TRUE, only return views, not displays.

string $filter

Filters the views on status. Can either be 'all' (default), 'enabled' or 'disabled'

mixed $exclude_view

View or current display to exclude. Either a:

  • views object (containing $exclude_view->storage->name and $exclude_view->current_display)
  • views name as string: e.g. my_view
  • views name and display id (separated by ':'): e.g. my_view:default
bool $optgroup

If TRUE, returns an array with optgroups for each view (will be ignored for $views_only = TRUE). Can be used by select

bool $sort

If TRUE, the list of views is sorted ascending.

Return Value

array

An associative array for use in select.

  • key: view name and display id separated by ':', or the view name only.

static array pluginList()

Returns a list of plugins and metadata about them.

Return Value

array

An array keyed by PLUGIN_TYPE:PLUGIN_NAME, like 'display:page' or 'pager:full', containing an array with the following keys:

  • title: The plugin's title.
  • type: The plugin type.
  • module: The module providing the plugin.
  • views: An array of enabled Views that are currently using this plugin, keyed by machine name.

static array getHandlerTypes()

Provide a list of views handler types used in a view, with some information about them.

Return Value

array

An array of associative arrays containing:

  • title: The title of the handler type.
  • ltitle: The lowercase title of the handler type.
  • stitle: A singular title of the handler type.
  • lstitle: A singular lowercase title of the handler type.
  • plural: Plural version of the handler type.
  • (optional) type: The actual internal used handler type. This key is just used for header,footer,empty to link to the internal type: area.

static array getPluginTypes(string $type = NULL)

Returns a list of plugin types.

Parameters

string $type

(optional) filter the list of plugins by type. Available options are 'plugin' or 'handler'.

Return Value

array

An array of plugin types.

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

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

See the t() documentation for details.

Parameters

$string
array $args
array $options