VariantInterface
interface VariantInterface implements PluginInspectionInterface, ConfigurableInterface, DependentPluginInterface, PluginFormInterface, RefinableCacheableDependencyInterface (View source)
Provides an interface for DisplayVariant plugins.
Methods
Gets the definition of the plugin implementation.
Sets the configuration for this plugin instance.
Calculates dependencies for the configured plugin.
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Adds cache contexts.
Merges the maximum age (in seconds) with the existing maximum age.
Adds a dependency on an object: merges its cacheability metadata.
Returns the user-facing display variant label.
Returns the admin-facing display variant label.
Returns the unique ID for the display variant.
Returns the weight of the display variant.
Sets the weight of the display variant.
Builds and returns the renderable array for the display variant.
Details
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
array
getConfiguration()
Gets this plugin's configuration.
setConfiguration(array $configuration)
Sets the configuration for this plugin instance.
array
defaultConfiguration()
Gets default configuration for this plugin.
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.
array
buildConfigurationForm(array $form, FormStateInterface $form_state)
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and
array_parents, see \Drupal\Core\Render\Element\FormElement.
validateConfigurationForm(array $form, FormStateInterface $form_state)
Form validation handler.
submitConfigurationForm(array $form, FormStateInterface $form_state)
Form submission handler.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
$this
addCacheContexts(array $cache_contexts)
Adds cache contexts.
$this
addCacheTags(array $cache_tags)
Adds cache tags.
$this
mergeCacheMaxAge(int $max_age)
Merges the maximum age (in seconds) with the existing maximum age.
The max age will be set to the given value if it is lower than the existing value.
$this
addCacheableDependency(CacheableDependencyInterface|object $other_object)
Adds a dependency on an object: merges its cacheability metadata.
string
label()
Returns the user-facing display variant label.
string
adminLabel()
Returns the admin-facing display variant label.
This is for the type of display variant, not the configured variant itself.
string
id()
Returns the unique ID for the display variant.
int
getWeight()
Returns the weight of the display variant.
setWeight(int $weight)
Sets the weight of the display variant.
bool
access(AccountInterface $account = NULL)
Determines if this display variant is accessible.
array
build()
Builds and returns the renderable array for the display variant.
The variant can contain cacheability metadata for the configuration that was passed in setConfiguration(). In the build() method, this should be added to the render array that is returned.