PathPluginBase
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
Constructs a PathPluginBase object.
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Creates an instance of the plugin.
Initialize the plugin.
Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions().
Fills up the options of the plugin with defaults.
Filter out stored options depending on the defined options.
Do the work to filter out stored options depending on the defined options.
Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
Provide a form to edit options for this plugin.
Lists the trusted callbacks provided by the implementing class.
Handle any special handling on the validate form.
Provide a full list of possible theme templates used by this style.
Validate that the plugin is correct and can be saved.
Returns a string with any core tokens replaced.
Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin.
Returns an array of available token replacements.
Adds elements for available core tokens to a form.
Moves form elements into fieldsets for presentation purposes.
Flattens the structure of form elements.
Calculates dependencies for the configured plugin.
Makes an array of languages, optionally including special languages.
Returns substitutions for Views queries for languages.
Calculates and returns dependencies of a specific plugin instance.
Calculates and adds dependencies of a specific plugin instance.
Initializes the display plugin.
Determines if this display should display the exposed filters widgets.
Should the enabled display more link be shown when no more items?
Determines whether this display can use attachments.
Allows displays to attach to other views.
Lists the 'defaultable' sections and what items each section contains.
Checks to see if the display has a 'path' field.
Checks to see if the display has some need to link to another display.
Checks to see if the display can put the exposed form in a block.
Find out all displays which are attached to this display.
Returns the base path to use for this display.
Points to the display which can be linked by this display.
Returns a URL to $this display or its configured linked display.
Determines if an option is set to use the default or current display.
Get the instance of a plugin, for example style or row.
Get a full array of handlers for $type. This caches them.
Gets all the handlers used by the display.
Gets all the plugins used by the display.
Retrieves a list of fields for the current display.
Sets an option, on this display or the default display.
Set an option and force it to be an override.
Returns a link to a section of a form.
Provides the default summary for options in the views UI.
If override/revert was clicked, perform the proper toggle.
Flip the override setting for the given section.
Applies the cacheability of the current display to the given render array.
pre_render callback for view display rendering.
Renders one of the available areas.
Determines if the user has access to this display of the view.
Calculates the display's cache metadata by inspecting each handler/plugin.
Executes the view and returns data in the format required.
Builds a renderable array of the view.
Builds a basic render array which can be properly render cached.
Checks if the provided identifier is unique.
Provides the block system with any exposed widget blocks for this display.
Reacts on deleting a display.
Returns the available rendering strategies for language-aware entities.
Returns whether the base table is of a translatable entity type.
Determines if this display's path is a default tab.
Generates a route entry for a given view and display.
Adds the route entry of a view to the collection.
Determines whether the view overrides the given route.
Determines whether an override for the path and method should happen.
Alters a collection of routes and replaces definitions to the view.
Gets menu links, if this display provides some.
Validates the path of the display.
Generates a URL to this display.
Returns the route name for the display.
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.
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.
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
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
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.
MessengerInterface
messenger()
Gets the messenger.
static ContainerFactoryPluginInterface
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.
protected array
defineOptions()
Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions().
protected
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.
protected
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.
Trusted callbacks are public methods on the implementing class and can be invoked via \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback().
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.
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.
protected 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.
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().
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.
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.
string
getProvider()
Returns the plugin provider.
protected 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.
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.
protected RendererInterface
getRenderer()
Returns the render API renderer.
protected $this
addDependency(string $type, string $name)
Adds a dependency.
protected
addDependencies(array $dependencies)
Adds multiple dependencies.
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.
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.
protected ModuleHandlerInterface
moduleHandler()
Wraps the module handler.
protected ThemeHandlerInterface
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.
'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.
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.
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.
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.
ViewsPluginInterface
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.
ViewsHandlerInterface[]
getHandlers($type)
Get a full array of handlers for $type. This caches them.
protected ViewsHandlerInterface[]
getAllHandlers(bool $only_overrides = FALSE)
Gets all the handlers used by the display.
protected ViewsPluginInterface[]
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.
This also takes into account any associated relationships, if they exist.
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.
Because forms may be split up into sections, this provides an easy URL to exactly the right section. Don't override this.
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.
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.
protected Url
getMoreUrl()
Get the more URL for this view.
Uses the custom URL if there is one, otherwise the display path.
render()
Renders this display.
protected
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.
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.
CacheableMetadata
getCacheMetadata()
Gets 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.
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.
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.
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.
If a view has no result and neither the empty, nor the footer nor the header does show anything return FALSE.
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.
protected
mergePlugin(string $type)
Merges plugins default values.
protected
mergeHandler(string $type)
Merges handlers default values.
DisplayExtenderPluginBase[]
getExtenders()
Gets the display extenders.
protected array
buildRenderingLanguageOptions()
Returns the available rendering strategies for language-aware entities.
protected bool
isBaseTableTranslatable()
Returns whether the base table is of a translatable entity type.
protected bool
isDefaultTabPath()
Determines if this display's path is a default tab.
protected 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.
protected bool
overrideApplies(string $view_path, Route $view_route, Route $route)
Determines whether the view overrides 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.
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.
array
getMenuLinks()
Gets menu links, if this display provides some.
protected 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.
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.
string[]
getAlteredRouteNames()
Returns the list of routes overridden by Views.